Home › Forums › Your projects › Structural Health Monitoring with Raspberry PI and Arduino with LoRa
Tagged: Arduino, lora, Raspberry PI
- This topic has 4 replies, 1 voice, and was last updated 4 years, 8 months ago by
Ricardo.
-
AuthorPosts
-
-
8 September 2020 at 00:31 #6156
Ricardo
Hi Renzo,
I’m developing a sensor network to monitor acceleration in different point of a building, this sensors (Arduino Compatible) communicate wirelessly to a master node (Raspberry Pi 4B) with LoRa (i tried NRF24L01+ modules but these have short range in interiors).
My goal is to send acceleration data (in real time or differed) from de arduino to the rpi using Ebyte E32-TTL-100 modules. The sensor (arduino uno) read aceleration 10 minutes every hour while/before sending the data to de rpi, then run to sleep mode for 50 minutes to save battery. Once in a time, sensors have to recieve configuration data from the rpi for calibration, syncronization, etc.
I’m getting started with LoRa and i have been researching, your page and library is the most promising, your job is awesome. I’m writing to read your recomendations and if you have any similar example or conecctions diagrams. My worry now is using different modes (normal and sleep), using the module in raspberry pi and if the module can produce noise in the readings of the accelerometer (if sending in real time).
An option instead of using arduino nano board and E32-TTL-100 module in the sensor is using Esp32 TTGO-LoRa32 915MHz board.
Hope to hear you reply, thank you for your time.
Ricardo.
-
8 September 2020 at 07:31 #6158
Hi Ricardo,
EByte E32 are suitable for your pourpuse.
I create a little project with WeMos D1 mini (esp8266) and LoRa E32 to control and fill water tank that have similar behaivor:
- a master with relay to activate pump, a simple oled display to show status an encoder to manage menù;
- a client that is powered by battery that are in sleep mode and have 2 water sensor level.
This devices communicate in this manner
- master send a wake message to a remote E32 that wake up;
- client check water level sensors;
- send current level to the master and go to sleep;
- master receive message and if te tank is not full start pump;
- when client is waked up by max level sensor send a new message to master with the new status and wait for ACK message;
- master receive message stop pump and send ACK.
To manage wake of an Arduino up you can refer to this article Ebyte LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) microcontroller and new Arduino shield
For Raspberry I don’t have a library, and you have 2 way:
- implement base serial command in Raspberry and use a EByte USB TTLlike so (code is not functional example)
#!/usr/bin/env python import time import serial ser = serial.Serial( port='/dev/ttyS0', #Replace ttyS0 with ttyAM0 for Pi1,Pi2,Pi0 baudrate = 9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1 ) ser.write('')
- but I’m going to release a REST server implemented in an esp8266 or esp32 that you can control via GET and POST in this way, and receive messages in realtime via WebSocket
REST server on esp8266 and esp32: introduction
with this base I create this web interface
I think the second way simplify your work a lot, but you must have patience, because I need more time to publish that.
But I’m here if you need more information.
Bye Renzo
-
9 September 2020 at 00:05 #6183
Ricardo
Thank you for your reply. I will try using USB TTL for now. Is it possible to run normal mode for a few minutes and then sleep mode for more minutes or the only way to do this is using wake up mode?
Thanks again! Ricardo.
-
9 September 2020 at 07:49 #6193
Hi Ricardo,
first of all, I forgot to advise you to use a device with 3.3v logic, even if the e32s still need to be powered at 5v, but the communication logic is at 3.3v, and your connection scheme will be simpler.
Than, here some pieces of code of one of my project:
Here I put my esp8266 and the E32 in sleep mode:
if (e32ttl.available()){ SERIAL_DEBUG.println("Start reading!"); ResponseContainer rs = e32ttl.receiveMessage(); String message = rs.data; SERIAL_DEBUG.println(rs.status.getResponseDescription()); SERIAL_DEBUG.println(message); deserializeJson(doc, message); String type = doc["type"]; SERIAL_DEBUG.print("type --> "); SERIAL_DEBUG.println(type); operationalSelected = static_cast((int)doc["mode"]); ResponseStatus rsW; if (type=="start"){ pumpIsActive = true; SERIAL_DEBUG.print(rsW.getResponseDescription()); SERIAL_DEBUG.println("Operation complete!!"); if (batteryLevel>1){ batteryTimePassed = 0; btSended = false; } }else if(type=="stopp"){ batteryTimePassed = 0; pumpIsActive = false; ResponseStatus rsUpdate = sendUpdate(PACKET_PUMP_LEVEL); SERIAL_DEBUG.println(rsUpdate.getResponseDescription()); rsW = setModeSleep(); SERIAL_DEBUG.print(rsW.getResponseDescription()); SERIAL_DEBUG.println("Operation complete, go to sleep!!"); }else if (type=="ackpa"){ needAck = false; } ResponseStatus rsUpdate = sendUpdate(PACKET_PUMP_LEVEL); SERIAL_DEBUG.println(rsUpdate.getResponseDescription()); SERIAL_DEBUG.println("Update complete!!"); timePassed = millis(); }
To send the update message
sendUpdate
you must set mode normalResponseStatus rs; rs.code = e32ttl.setMode(MODE_0_NORMAL);
than start to send message
ResponseStatus rsSend = e32ttl.sendFixedMessage(SERVER_ADDH, SERVER_ADDL, SERVER_CHANNEL, buf, size); SERIAL_DEBUG.println(rsSend.getResponseDescription()); if (rsSend.code==SUCCESS && needAckParam){ ackStartTime = millis(); needAck = true; } return rsSend;
I think It’s what you want to know.
Bye Renzo
-
10 September 2020 at 00:48 #6225
Ricardo
Thanks very much Renzo, i will try your recomendation.
-
-
AuthorPosts
- You must be logged in to reply to this topic.