Differences

This shows you the differences between two versions of the page.

Link to this comparison view

iothings:proiecte:2022:long_distance_communication [2023/01/19 19:18]
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 nodeand from there to plot received data on a chart from a website created by the ESP32.
  
 ====== Hardware ====== ====== Hardware ======
  
-== Bill of materials (BOM) ==+===== Bill of materials (BOM) =====
  
 - 1 x ESP32 WROVER KIT (in this case: T18 3.0) - 1 x ESP32 WROVER KIT (in this case: T18 3.0)
Line 22: Line 22:
  
  
-== Schematic ==+===== Schematic ​=====
  
 {{schematic.png?​700x300}} {{schematic.png?​700x300}}
Line 28: Line 28:
 ---- ----
  
-== Experimental setup ==+===== Experimental setup =====
  
 {{experiment.png?​700x300}} {{experiment.png?​700x300}}
Line 34: Line 34:
 ---- ----
  
-== Description of the setup ==+===== Description of the setup =====
  
-1. nRF24L01+ PA + LNA+==== 1. nRF24L01+ PA + LNA ====
  
 It is a low cost wireless communication module, created by Nordic Semiconductor,​ that comes with an antenna for long distance range. It is a low cost wireless communication module, created by Nordic Semiconductor,​ that comes with an antenna for long distance range.
Line 57: Line 57:
  
  
-{{:​iothings:​proiecte:​2022:​nrf24l01.jpg?​300x300|}}+{{:​iothings:​proiecte:​2022:​nrf24l01.jpg?​200x200|}}
  
 +{{:​iothings:​proiecte:​2022:​pinout-nrf24l01.png?​400|}}
 +
 +
 +
 +==== 2. Sound sensor module ====
 +
 +This is very cheap sound sensor, with a very simple interface, with digital output.
 +This module contains a trigger Schmitt, so it can only detect sound presence and can not be used to measure sound intensity, frequency or any analog parameter.\\
 +It also contains an potentiometer to adjust the offset of the amplifier for the specific application.\\
 +
 +{{:​iothings:​proiecte:​2022:​senzor-sunet.jpg?​200|}}
 +
 +
 +
 +===== Real setup =====
 +
 +ESP32 setup:\\
 +{{:​iothings:​proiecte:​2022:​img_20230118_163822_2.jpg?​500x300|}}
 +
 +Arduino setup:\\
 +{{:​iothings:​proiecte:​2022:​img_20230118_164223_2.jpg?​500x300|}}
 +
 +
 +As can the seen, the Arduino board has to be powered from battery because it will be placed far away from the computer.
  
 ====== Software ====== ====== Software ======
 +
 +Tools used: Arduino IDE, nRF24L01 library.\\
 +
 +
  
 Because the nRF24L01 module is using SPI communication,​ step zero is to assure the ESP32 TTY board supports SPI communication and find out pins of this specific module board. Easy task, just run a small script to findout SPI pinouts: '​MISO',​ '​MOSI',​ '​SS',​ '​CLK'​. Because the nRF24L01 module is using SPI communication,​ step zero is to assure the ESP32 TTY board supports SPI communication and find out pins of this specific module board. Easy task, just run a small script to findout SPI pinouts: '​MISO',​ '​MOSI',​ '​SS',​ '​CLK'​.
Line 66: Line 94:
 Next step is to establish the wireless communication between the 2 master modules: Arduino and ESP32.\\ Next step is to establish the wireless communication between the 2 master modules: Arduino and ESP32.\\
 Arduino is the transmitter and ESP32 is the receiver.\\ Arduino is the transmitter and ESP32 is the receiver.\\
 +
 A demo code for the Arduino (Uno - matters only for the pinout) can be seen in the code appendix ((Arduino transmitter code example)).\\ A demo code for the Arduino (Uno - matters only for the pinout) can be seen in the code appendix ((Arduino transmitter code example)).\\
 And the ESP32 will be the received, code example here ((ESP32 code receiver)).\\ And the ESP32 will be the received, code example here ((ESP32 code receiver)).\\
-(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. \\
 +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.\\
 +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?​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 82: Line 131:
  
 Arduino transmitter code example:\\ Arduino transmitter code example:\\
 +
 <​code>​ <​code>​
 #include <​SPI.h>​ #include <​SPI.h>​
Line 112: Line 162:
  
 ESP32 received code example:\\ ESP32 received code example:\\
 +
 <​code>​ <​code>​
 #include <​SPI.h>​ #include <​SPI.h>​
Line 139: Line 190:
  }  }
  else{  else{
-  //​Serial.println("​No radio available"​);​ 
  }  }
 } }
 </​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>​
 +
iothings/proiecte/2022/long_distance_communication.1674148738.txt.gz · Last modified: 2023/01/19 19:18 by ioan.turturea
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0