• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

SHT20 sensor and Heltec Wifi Lora 32

Q&A Forum › SHT20 sensor and Heltec Wifi Lora 32
0 Vote Up Vote Down
Nazmie Razali asked 6 years ago

Hi Rui, I’m using Heltec Wifi Lora 32 and SHT20 sensor for my Lora sender project (with a display). without display code in the project, the sensor worked fine and after the display code were added, the sensor did not showed a correct value. Below is the code that I used (bold font for display):

//OLED
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h> //Oled display
//SHT20
#include <Wire.h> //allows communication with I2C
#include "DFRobot_SHT20.h" //SHT20 library
DFRobot_SHT20 sht20;
//LoRa
#include <SPI.h> //(Serial Peripheral Interface - communication protocol)
#include <LoRa.h>
//define the pins used by the transceiver module
#define ss 18
#define rst 14
#define dio0 26

#define OLED_RESET 16 //OLED
Adafruit_SSD1306 display(OLED_RESET);
String message; //variable for data packet (LoRa)

void setup() 
{
//****SHT20
Serial.begin(115200);
Serial.println("SHT20 Example!");
sht20.initSHT20(); // Init SHT20 Sensor
delay(1000);
sht20.checkSHT20(); // Check SHT20 Sensor
/* //****OLED display setup
Wire.begin(4,15);
display.begin(SSD1306_SWITCHCAPVCC, 0x3c);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("Initializing...");
display.display(); */

//****LoRa
//setup LoRa transceiver module
LoRa.setPins(ss, rst, dio0);

//replace the LoRa.begin(---E-) argument with your location's frequency 
//433E6 for Asia
//866E6 for Europe
//915E6 for North America
if (!LoRa.begin(915E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
Serial.println("LoRa Initializing OK!");

}
void loop() 
{
//****SHT20
float humd = sht20.readHumidity(); // Read Humidity
float temp = sht20.readTemperature(); // Read Temperature
//Serial.print("Time:");
//Serial.print(millis());
Serial.print(" Temperature:");
Serial.print(temp, 1);
Serial.print("C\t");
Serial.print(" Humidity:");
Serial.print(humd, 1);
Serial.print("%");
Serial.println();
//delay(1000);
message = String (1) + "/"
+String(temp,1) + "&"
+String(humd,1) + "#"; //Variable management

/* //****OLED
display.clearDisplay();
display.setCursor(0,0);
//display.print("Time:");
//display.print(millis());
display.print("\nTemperature:");
display.print(temp,1); //1 is decimal place
display.print("C");
display.print("\nHumidity:");
display.print(humd,1);
display.print("%");
display.display(); */
//****LoRa
//Send LoRa packet to receiver
LoRa.beginPacket(); 
LoRa.print(message);
LoRa.endPacket();
delay(1000);

}

hope you can help me, thank you.

2 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Hello, unfortunately I’ve never used the SHT20 module before, so I don’t know how to read from it exactly/ I don’t have any examples with it…
Thanks for asking!

0 Vote Up Vote Down
Nazmie Razali answered 6 years ago

Thats okay Rui, thank you.

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.