Creating an IoT platform for smart agriculture. Collecting data and sending them to thingspeak for analysis
Dependencies: DHT11 LPS22HB LSM6DSL VL53L0X
CANbus.h@0:07ff689741d2, 2018-06-08 (annotated)
- Committer:
- kaoriw
- Date:
- Fri Jun 08 12:00:02 2018 +0000
- Revision:
- 0:07ff689741d2
IoT project (CAN message packing not working + problem with compiling SPI)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kaoriw | 0:07ff689741d2 | 1 | #ifndef CANBUS_H |
kaoriw | 0:07ff689741d2 | 2 | #define CANBUS_H |
kaoriw | 0:07ff689741d2 | 3 | |
kaoriw | 0:07ff689741d2 | 4 | #include "mbed.h" |
kaoriw | 0:07ff689741d2 | 5 | |
kaoriw | 0:07ff689741d2 | 6 | /* Variables for collecting values */ |
kaoriw | 0:07ff689741d2 | 7 | int battery_current, battery_voltage, Bat_SOC, speed, motorTemperature; |
kaoriw | 0:07ff689741d2 | 8 | |
kaoriw | 0:07ff689741d2 | 9 | /* Configure CAN pins */ |
kaoriw | 0:07ff689741d2 | 10 | CAN can(D15, D14); |
kaoriw | 0:07ff689741d2 | 11 | |
kaoriw | 0:07ff689741d2 | 12 | /* Functions */ |
kaoriw | 0:07ff689741d2 | 13 | struct VMS_Msg1 data_pack(int* data); |
kaoriw | 0:07ff689741d2 | 14 | void data_parse(struct VMS_Msg1 packed_data); |
kaoriw | 0:07ff689741d2 | 15 | |
kaoriw | 0:07ff689741d2 | 16 | #pragma pack(push, 1) |
kaoriw | 0:07ff689741d2 | 17 | struct VMS_Msg1{ |
kaoriw | 0:07ff689741d2 | 18 | int battery_current:16; |
kaoriw | 0:07ff689741d2 | 19 | int battery_voltage:8; |
kaoriw | 0:07ff689741d2 | 20 | int Bat_SOC:8; |
kaoriw | 0:07ff689741d2 | 21 | int speed:8; |
kaoriw | 0:07ff689741d2 | 22 | int motorTemperature:8; |
kaoriw | 0:07ff689741d2 | 23 | int Gear:2; |
kaoriw | 0:07ff689741d2 | 24 | int KeyLocation:2; |
kaoriw | 0:07ff689741d2 | 25 | int downrating:1; |
kaoriw | 0:07ff689741d2 | 26 | int AirCondEnable:1; |
kaoriw | 0:07ff689741d2 | 27 | int PEPScert:2; |
kaoriw | 0:07ff689741d2 | 28 | int ReadySignal:8; |
kaoriw | 0:07ff689741d2 | 29 | }VMS_Msg1; |
kaoriw | 0:07ff689741d2 | 30 | #pragma pack(pop) |
kaoriw | 0:07ff689741d2 | 31 | |
kaoriw | 0:07ff689741d2 | 32 | |
kaoriw | 0:07ff689741d2 | 33 | #endif |