Esp8266 DHT11 Humidity & Temperature but Failed to read from DHT sensor - arduino-esp8266

Help please
I'm trying to get the sensor values from DHT11 Humidity & Temperature Sensor but the Esp8266 is connecting to internet but is not reading the value from the sensor.
I'm using Blynk to display the sensor value
this is what appears in my monitors Serial
21:41:24.811 -> �����������������������������������������������������������������������������������������������[24759] Connected to WiFi
21:41:26.726 -> [24759] IP: 192.168.1.9
21:41:26.760 -> [24759]
21:41:26.760 -> ___ __ __
21:41:26.796 -> / _ )/ /_ _____ / /__
21:41:26.796 -> / _ / / // / _ \/ '_/
21:41:26.832 -> /____/_/\_, /_//_/_/\_\
21:41:26.865 -> /___/ v0.5.4 on NodeMCU
21:41:26.903 ->
21:41:26.903 -> [24837] Connecting to blynk-cloud.com:80
21:41:30.876 -> [28951] Ready (ping: 23ms).
21:41:34.230 -> Failed to read from DHT sensor!
21:41:34.940 -> Failed to read from DHT sensor!
21:42:56.217 -> Failed to read from DHT sensor!
my code
my current circuit diagram

Double check the connection of sensor and its variable define in code, it has to be the same, most projects with esp use D4 for dht input.
Try to put 4k7 to 10k resistor between +VCC and dht's data out pin.

Related

Weird bug in i2c between Arduino and Raspberry Pi 4B

I have a weird bug when I'm sending data from Arduino Mega via I2C to Raspberry Pi 4B.
Arduino Mega is working as slave and Raspberry Pi as master. Raspberry Pi request data from Arduino and it sends a string of letters and numbers that look like this(no newline on the end):
xxE5xNx
but Raspberry Pi receives:
xxE5xN#
For sure that's not a issue with wiring, because I tested sending and receiving of 1000 packets without any error.
This bug does not happen when I change 'E', '5' or 'N' to another character or delete first two characters. When changing any of 'x' to another character bug still exists. Why?
Minimal code for reproducing:
Arduino Mega(slave):
#include <Wire.h>
String s = "xxE5xNx";
void i2cRequest(){
Wire.print(s);
}
void setup() {
Wire.begin(0x01);
Wire.onRequest(i2cRequest);
}
void loop() {}
Raspberry Pi 4B(master):
from smbus2 import SMBus
bus = SMBus(1)
data = bus.read_i2c_block_data(0x01, 0, 32)
text = ""
for m in data:
if(m != 255): text += chr(m)
print(text)

HC-05 Bluetooth Serial Sometime getting wrong value

I have Connected HC-05 with Arduino UNO I'm sending Integer value Example:
Send Receive
10 10
11 0
15 15
18 2541
Sometime getting correct Data and sometime getting wrong Data.
Global:
//Bluetooth
#define BLUETOOTH_SPEED 9600
SoftwareSerial bluetooth(10, 11);
Setup:
bluetooth.begin(BLUETOOTH_SPEED);
Loop:
if (bluetooth.available() > 0) {
integerValue = 0;
while (bluetooth.available() > 0) {
byte incoming = bluetooth.read();
//Serial.println(incoming);
if (incoming >= '0' && incoming <= '9') {
integerValue = (integerValue * 10) + (incoming - '0');
//delay(5);
}
}
bluetooth.flush();
Serial.println(integerValue);
SoftwareSerial on Arduino is essentially a half-duplex type of communication. You may have dedicated transmit and receive pins, but the same timer is used for transmitting and receiving. So you can't do both transmitting and receiving work on the SoftwareSerial object at the same time.
This part of your code makes me think that you are transmitting something inside some other part of the code.
bluetooth.flush();
If you are, you will have to implement some form of flow control to ensure that you are not transmitting and receiving something on SoftwareSerial object at the same time.

ZS-040 (HC-05) Bluetooth module doesn't respond to AT

Hello,
so I have bought a ZS-040 HC-05 Arduino Bluetooth module and I want to change its name. I've learned, that you have to do that in AT Mode. I followed all instructions at http://www.martyncurrey.com/arduino-with-hc-05-bluetooth-module-at-mode/ I succesfully entered the AT Mode (Red LED is Blinking every 2 Seconds), but when I enter AT into the Serial Monitor, i get nothing.
This is my Arduino Code (preaty much exactly the same as described in that article)
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
char c = ' ';
void setup()
{
Serial.begin(9600);
Serial.println("Arduino is ready");
Serial.println("Remember to select Both NL & CR in the serial monitor");
BTserial.begin(38400);
}
void loop()
{
if (BTserial.available())
{
c = BTserial.read();
Serial.write(c);
}
if (Serial.available())
{
c = Serial.read();
BTserial.write(c);
}
}
Everything is connected as described in Method 1 (Other Methods doesn't work for me). I've set the Serial Monitors Baud to 9600 and to Both NL and CR.
If someone has experiense with this problem and solved it, please help :)
Thank you all very much!
I struggled with this for a while.
Upload a blank sketch (void setup(){} void loop(){})
Attach bluetooth module RX to RX on the Arduino (pin0) and TX to TX (pin1)
Insert ground wire from Bluetooth to G on the Arduino and EN to 3.3v
Power the Arduino
Insert the VCC from Bluetooth into 5v while holding down the small button on the bluetooth.
Bluetooth should have a very slow blink now, indicating it is in command mode.
Open the serial monitor on your computer. Set the baud rate to 38400. You will be able to test the connection by typing 'at'. It should respond 'OK' - try typing 'at' a second time if the first time receives an error.
the reason why this connection works is because 0 and 1 pins are used by the serial monitor when communicating with the Arduino. No program is need because it is the default connection when the monitor is opened.
I hope this helps.

Bluetooth data shown as 0X80 instead of 0X00

I have been using Bluetooth module (HC-05) with Atmega8(both A and L) microcontroller to transmit data to my Android device. In following code an 8-bit signed(or unsigned doesn't made any change) value is sent over bluetooth to be displayed on device, this value starts at 0X00 and is incremented in every iteration:
#define F_CPU 1000000
#define BAUD 9600
#define MYUBRR (F_CPU/16/BAUD-1)
#include <avr/io.h>
#include <util/delay.h>
int main (void)
{
uint8_t data = 0;
UBRRH = (MYUBRR >> 8); // setting higher bits of UBRR
UBRRL = MYUBRR; // setting lower bit of UBRR
UCSRB = (1 << TXEN); // transmit enable
UCSRC = ((1 << URSEL) | (1 << UCSZ1) | (1 << UCSZ0)); //URSEL=USART reg selection (R/W), UCSZ1 & UCSZ0 set equal to 011 that is 8 bit data size
while (1)
{
UDR=data; // loading data in USART Data register (8-bit) and it will be transmitted immidiately
while(!(UCSRA&(1<<UDRE))); // waiting till complete data sent and UDRE flag set
_delay_ms(200); // after some time
data++; // incrementing data
}
return 0;
}
On the android device end there is "Bluetooth spp Pro" app to display the recieved data on screen.
Following is the configuration of recieve mode (Data is displayed as Hex values):
The data recieved here should start at 0X00 and go up to 0XFF instead it starts at 0X80 and increments upto 0XFF in a very unfamiliar manner.
Referring above image. The pattern I observed here is that the tens place digit starts at 8 and units place change from 0 to F then in next loop again it becomes 9 and unit place change from 0 to F after that instead of incrementing (expected) tens place again goes to 8 and then in next cycle it again becomes 9, after these four cycles of two repetetive words tens place increments to A and units place change from 0 to F and later the strange tens place pattern reappears for A and B then for C and D and later for E and F at tens place.
So my concern is:
Why is the device showing 80 for 00, as it is correctly working for ones place why is it not working for tens place as expected???
Thanks!!!
Edit:
This problem is neither Android version nor device manufacturer specific.
Problem was with voltage levels. Operating the microcontroller circuit on 3.2V and Bluetooth module on 3.8V solved the problem and data is transmitted as expected. However I am unable to predict an explanation for this.
Please help.
It is observed clearly on varying the potentiometer of voltage regulator, when I keep it below 3.20V data is transmitted smooth, and as the voltage level crosses 3.20V the tens place of data starts getting corrupted up to the point of complete data corruption and output becomes constant data 0XFE at 3.8V.

generating EXTI0 interrupt when extenal temperature sensor is connected to STM32F207VC

I am using STM32F207VC controller . I have my external probe temperature sensor connected to one of the internal ADC channel of stm32.
I want to generate an external interrupt when this is connected to controller and i should start measuring from external temperature sensor.
Please could any one provide me code or any help in this
Thanks
I have an STM32F4 processor interfaced with a Solomon Systems SSD1963 GPU. The GPU has a Tearing Signal (TE) that notifies the processor when it is about to do a vertical refresh. I hope you can use this code as an example and adapt it to your solution.
The TE signal is connected to the CPU's GPIO G7 pin. So first I have to configure the GPIO pin.
//GPIO Pin G7
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOG, &GPIO_InitStructure);
Next I have to configure the interrupt and NVIC.
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOG, EXTI_PinSource7);
EXTI_InitTypeDef EXTI_InitStructure;
EXTI_StructInit(&EXTI_InitStructure);
EXTI_InitStructure.EXTI_Line = EXTI_Line7;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
Finally I have to create the interrupt handler. The EXTI9_5_IRQHandler handles external interrupts on lines 5 ~ 7. This method is actually defined in my CPUs startup assembly file as a weak reference. I just need to redefine the method and the linker will do the rest.
extern "C" void EXTI9_5_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line7) != RESET)
{
//Handle the interrupt
EXTI_ClearITPendingBit(EXTI_Line7);
}
}
I'm using Mentor Graphics' Sourcery Codebench Lite as my toolchain.

Resources