See: https://github.com/EEEManchester/Food-Computer

Dependencies:   DHT DS1820 MODSERIAL ModbusSlave232 SoftSerial TSL2561_I2C mbed millis

Fork of ModbusRTU-RS232 by Afdhal Atiff Tan

Committer:
AfdhalAtiffTan
Date:
Thu Jul 28 13:23:10 2016 +0000
Revision:
1:77e7cf856fae
First Rev_1 alpha code. May contain bugs. All sensors and actuators should be working. Doesn't use RTOS because SoftSerial can't handle it, it uses Ticker instead. Communication via MODBUS RTU on serial.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AfdhalAtiffTan 1:77e7cf856fae 1 //for modbus
AfdhalAtiffTan 1:77e7cf856fae 2 const unsigned char SLAVE = 1;
AfdhalAtiffTan 1:77e7cf856fae 3 const long BAUD = 9600;
AfdhalAtiffTan 1:77e7cf856fae 4 const unsigned PARITY = 'n';
AfdhalAtiffTan 1:77e7cf856fae 5 ModbusSlave232 mbs; // Create new mbs instance
AfdhalAtiffTan 1:77e7cf856fae 6
AfdhalAtiffTan 1:77e7cf856fae 7 Ticker modbus_updater;
AfdhalAtiffTan 1:77e7cf856fae 8
AfdhalAtiffTan 1:77e7cf856fae 9 // Slave registers
AfdhalAtiffTan 1:77e7cf856fae 10 enum {
AfdhalAtiffTan 1:77e7cf856fae 11 MB_0, // Register 0 air_co2
AfdhalAtiffTan 1:77e7cf856fae 12 MB_1, // Register 1 air_humidity
AfdhalAtiffTan 1:77e7cf856fae 13 MB_2, // Register 2 air_temp
AfdhalAtiffTan 1:77e7cf856fae 14 MB_3, // Register 3 water_temp
AfdhalAtiffTan 1:77e7cf856fae 15 MB_4, // Register 4 water_ec
AfdhalAtiffTan 1:77e7cf856fae 16 MB_5, // Register 5 water_ph
AfdhalAtiffTan 1:77e7cf856fae 17 MB_6, // Register 6 light_lux
AfdhalAtiffTan 1:77e7cf856fae 18 MB_7, // Register 7 window_switch
AfdhalAtiffTan 1:77e7cf856fae 19 MB_8, // Register 8 shell_switch
AfdhalAtiffTan 1:77e7cf856fae 20 MB_9, // Register 9 relays
AfdhalAtiffTan 1:77e7cf856fae 21 MB_REGS // Dummy register. using 0 offset to keep size of array
AfdhalAtiffTan 1:77e7cf856fae 22 };
AfdhalAtiffTan 1:77e7cf856fae 23
AfdhalAtiffTan 1:77e7cf856fae 24 int regs[MB_REGS];
AfdhalAtiffTan 1:77e7cf856fae 25
AfdhalAtiffTan 1:77e7cf856fae 26 char co2string[32];
AfdhalAtiffTan 1:77e7cf856fae 27 int CO2_PPM;
AfdhalAtiffTan 1:77e7cf856fae 28 float water_temperature;