If you are new with AVR IoT Mini Cellular Board. Please refer to my other project, I will complete this project briefly and quickly. Similarly with Portable street light monitoring system, this project use AVR-IoT Cellular Mini.
SummaryBy monitoring the sunlight exposed to outdoor plants, it provides red and blue LED reinforcement when it is cloudy or rainy.
Why need to monitor sunlight exposed? We know that the growth of plants is closely related to light. By monitoring and controlling the amount of light, we can control the growth rate of plants. In cities, plants shaded by buildings can use this method to maintain their growth.
HardwareAVR-IoT Cellular Mini
Battery
Clear can
Red / Blue LED
SoftwareArduino
AdafruitIO
Buildstep.1 Set up Adafruit IO
Adafruit IO settings for this project
step.2 Arduino Coding
Reading sensor color values
SerialCDC.printf("Device ID: %x\r\n", Veml3328.deviceID());
Red_sensorvalue = Veml3328.getRed(); // red sensor peak 610 nm
Green_sensorvalue = Veml3328.getGreen(); // green sensor peak 560 nm
Blue_sensorvalue = Veml3328.getBlue(); // blue sensor peak 470 nm
SerialCDC.printf("R,G,B: %d,%d,%d\r\n", Red_sensorvalue,Green_sensorvalue,Blue_sensorvalue);
Publish topics
#define MQTT_PUB_TOPIC_red_light "momososo/feeds/farm.red-light"
#define MQTT_PUB_TOPIC_green_light "momososo/feeds/farm.green-light"
#define MQTT_PUB_TOPIC_blue_light "momososo/feeds/farm.blue-light"
#define MQTT_PUB_TOPIC_blue_temp "momososo/feeds/farm.temperature"
void MQTT_pub() {
bool publishedSuccessfully;
sprintf(sendbuffer, "%d", Red_sensorvalue );
publishedSuccessfully = MqttClient.publish(MQTT_PUB_TOPIC_red_light, sendbuffer);
if (publishedSuccessfully) {
Log.infof(F("Published red_light Success\r\n"));
} else {
Log.error(F("Failed to publish red_light"));
}
sprintf(sendbuffer, "%d", Green_sensorvalue );
publishedSuccessfully = MqttClient.publish(MQTT_PUB_TOPIC_green_light, sendbuffer);
if (publishedSuccessfully) {
Log.infof(F("Published green_light Success\r\n"));
} else {
Log.error(F("Failed to publish green_light"));
}
sprintf(sendbuffer, "%d", Blue_sensorvalue );
publishedSuccessfully = MqttClient.publish(MQTT_PUB_TOPIC_blue_light, sendbuffer);
if (publishedSuccessfully) {
Log.infof(F("Published blue_light Success\r\n"));
} else {
Log.error(F("Failed to publish blue_light"));
}
sprintf(sendbuffer, "%f", celsius );
publishedSuccessfully = MqttClient.publish(MQTT_PUB_TOPIC_blue_temp, sendbuffer);
if (publishedSuccessfully) {
Log.infof(F("Published temp Success\r\n"));
} else {
Log.error(F("Failed to publish temp"));
}
}
Subscribe topics and Turn on/off LEDs
void MQTT_subLED() {
String message_red = MqttClient.readMessage(MQTT_SUB_TOPIC_red_led);
String message_blue = MqttClient.readMessage(MQTT_SUB_TOPIC_blue_led);
String compareuse;
// Read message will return an empty string if there were no new
// messages, so anything other than that means that there was a new
// message
if (message_red != "") {
Log.infof(F("Red: %s\r\n"), message_red.c_str());
compareuse = message_red.c_str();
SerialCDC.println(compareuse);
if (compareuse == "OFF")
{
digitalWrite(LED_R_PIN, 0);
}
else if (compareuse == "ON")
{
digitalWrite(LED_R_PIN, 1);
}
}
if (message_blue != "") {
Log.infof(F("Blue: %s\r\n"), message_blue.c_str());
compareuse = message_blue.c_str();
SerialCDC.println(compareuse);
if (compareuse == "OFF")
{
digitalWrite(LED_B_PIN, 0);
}
else if (compareuse == "ON")
{
digitalWrite(LED_B_PIN, 1);
}
}
}
serial print out result
11:14:53.423 -> R,G,B: 39,58,38
11:14:53.423 -> TempC: 34.125000
11:14:55.527 -> [INFO] Published red_light Success
11:14:59.558 -> [INFO] Published green_light Success
11:15:01.010 -> [INFO] Published blue_light Success
11:15:01.430 -> [INFO] Published temp Success
11:15:01.476 -> [INFO] Red: ON
11:15:01.476 -> ON
11:15:01.476 -> [INFO] Blue: ON
11:15:01.476 -> ON
11:15:11.576 -> R,G,B: 40,58,38
11:15:11.576 -> TempC: 34.187500
11:15:12.091 -> [INFO] Published red_light Success
11:15:12.465 -> [INFO] Published green_light Success
11:15:13.729 -> [INFO] Published blue_light Success
11:15:14.150 -> [INFO] Published temp Success
11:15:14.150 -> [INFO] Red: OFF
11:15:14.150 -> OFF
11:15:14.150 -> [INFO] Blue: OFF
11:15:14.150 -> OFF
Don't know why the temperature is so high. Maybe it’s too close to the cellular module
step.3 Hardware connection
Since this is just a simple LED connection, please allow me to replace the circuit diagram with a picture.
step.4 Add actions on Adafruit IO
Setting on the cloud, when the light value is lower than a certain value, the same color LED light is turned on, and when it is higher, it is turned off.
- Linked to other devices, such as sprinklers, fertilizer spreaders, awnings.
- Linked camera to further observe the growth status of plants.
In this project, I proposed how to use Veml3328 to read the red, green and blue irradiation and upload the values to Adafruit IO. On the cloud, it is judged whether the spectral illumination is sufficient, and if it is not enough, the local LED is turned on.
Compared with other similar projects, this project can be more universally adapted to various crops. When you need to modify the exposure amount, you only need to adjust the settings on the cloud and do not need to update the device program.
Due to limited funds and time, I only used a single LED for demonstration. In actual application, professional plant lights are required. Arrange the number and power of lamps according to your crop area.
Comments