This shows you the differences between two versions of the page.
iothings:proiecte:2022:long_distance_communication [2023/01/19 19:56] ioan.turturea |
iothings:proiecte:2022:long_distance_communication [2023/01/20 08:14] (current) ioan.turturea |
||
---|---|---|---|
Line 3: | Line 3: | ||
====== Introduction ====== | ====== Introduction ====== | ||
- | This project has as final purpose, transmitting data over a long range, to a node which is an internet gate (in this case the ESP). | + | This project has as final purpose, transmitting sensor data over a long distance, to a node which is an internet gate (in this case the ESP32 node) and from there to plot received data on a chart from a website created by the ESP32. |
====== Hardware ====== | ====== Hardware ====== | ||
Line 57: | Line 57: | ||
- | {{:iothings:proiecte:2022:nrf24l01.jpg?300x300|}} | + | {{:iothings:proiecte:2022:nrf24l01.jpg?200x200|}} |
+ | |||
+ | {{:iothings:proiecte:2022:pinout-nrf24l01.png?400|}} | ||
Line 97: | Line 99: | ||
(note: nRF24L01 module can operate in full duplex mode, but in this project, only one way communication was used).\\ | (note: nRF24L01 module can operate in full duplex mode, but in this project, only one way communication was used).\\ | ||
+ | |||
+ | It is very important to test the setup in the environment in which will be used, because the distance between the 2 nodes can vary from 1100m in open field to even meter in, for example, concrete walls on the way. | ||
+ | |||
+ | |||
After the communication between the modules was established, it is time to send real data from the sound sensor. \\ | After the communication between the modules was established, it is time to send real data from the sound sensor. \\ | ||
As stated in the description of the sound sensor module, it can only transmit digital level to detect sound, not reply sound fidelity. \\ | As stated in the description of the sound sensor module, it can only transmit digital level to detect sound, not reply sound fidelity. \\ | ||
- | So in order to hack ;-) this a simple script to count time while sound level is high was used.\\ | + | So in order to hack this ;-) a simple script to count time while sound level is high was used.\\ |
- | Visualizing such data in the Serial Plotter, looks like a real microphone recording. | + | Visualizing such data in the Serial Plotter, looks like a real microphone recording. Code is the appendix ((sound sensor)) |
- | {{:iothings:proiecte:2022:plotter_serial.png?700x300|}} | + | {{:iothings:proiecte:2022:plotter_serial.png?700x200|}} |
+ | Last step is to create a web page hosted by the ESP32, that will be accessed by a PC to view collected data on charts.\\ | ||
+ | For this, laboratory 3 was used: | ||
+ | [[https://ocw.cs.pub.ro/courses/iothings/laboratoare/2022/lab3]] | ||
+ | |||
+ | Final information plotted in a chart on the webpage look like:\\ | ||
+ | {{:iothings:proiecte:2022:chart.png?600|}} | ||
====== Bibliography ====== | ====== Bibliography ====== | ||
Line 181: | Line 193: | ||
} | } | ||
</code> | </code> | ||
+ | |||
+ | |||
+ | Sound sensor code: | ||
+ | <code> | ||
+ | int soundPin = A0; | ||
+ | |||
+ | const int OUT_PIN = 8; | ||
+ | const int SAMPLE_TIME = 10; | ||
+ | unsigned long MillisCurrent; | ||
+ | unsigned long MillisLast; | ||
+ | unsigned long MillisElapsed; | ||
+ | int SampleBufferValue = 0; | ||
+ | |||
+ | void setup(void){ | ||
+ | Serial.begin(115200); | ||
+ | } | ||
+ | |||
+ | void loop(void) | ||
+ | { | ||
+ | MillisCurrent = millis(); | ||
+ | MillisElapsed = MillisCurrent - MillisLast; | ||
+ | if(digitalRead(OUT_PIN) == HIGH) | ||
+ | { | ||
+ | SampleBufferValue++; | ||
+ | } | ||
+ | |||
+ | if(MillisElapsed > SAMPLE_TIME){ | ||
+ | Serial.println(SampleBufferValue); | ||
+ | SampleBufferValue = 0; | ||
+ | MillisLast = MillisCurrent; | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ |