When I try to send character OpenMV to NodeMCU wifi module under the UART communication.But I failed.
Firstly this is my NodeMCU side codes:
When the serial communication avalible I have to see read_data
void setup() {
Serial.begin(115200); // Initialize the Serial interface with baud rate of 9600
}
// the loop function runs over and over again forever
void loop() {
if(Serial.available()>0) //Checks is there any data in buffer
{
Serial.print("We got:");
Serial.print(char(Serial.read())); //Read serial data byte and send back to serial monitor
}
else
{
Serial.println("Hello World..."); //Print Hello word every one second
delay(1000); // Wait for a second
}
}
When I connect to NodeMCU rx,tx pin to OpenMV P5 and P4 pins. Than when I just connect NodeMCU with usb cable to computer and upload code. And open terminal I can see “hello word” thats okey. But at the same time when I connect OpenMV with the usb cable to computer. I can not see anything but my openmv side send some cha character to nodemcu bu i can not see anything.
Where is my fault. Please help me ?
This is openmv side code:
import pyb
import sensor, image, time
# openMV standart settings:
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) # must turn this off to prevent image washout...
clock = time.clock()
[code]#uart initilazing P4:TX and P5:RX
uart = pyb.UART(3, 115200, timeout_char = 1000)
#tracking qr code and send to uart
while(True):
clock.tick()
img = sensor.snapshot()
img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens.
for code in img.find_qrcodes():
img.draw_rectangle(code.rect(), color = (255, 0, 0))
print(code.payload())
uart.write('h')
print(uart.read())
print(clock.fps())
[/code]