remove debug prints + add flask raspi code

This commit is contained in:
FluffyCube9343 2023-01-07 13:10:15 -05:00
parent 44a2a9ff45
commit 7fba995989
4 changed files with 17 additions and 15 deletions

View File

@ -1,11 +1,4 @@
/*
Program: Receive Strings From Raspberry Pi
File: receive_string_from_raspberrypi.ino
Description: Receive strings from a Raspberry Pi
Author: Addison Sears-Collins
Website: https://automaticaddison.com
Date: July 5, 2020
*/
int i=0;
void setup(){
@ -23,12 +16,11 @@ void loop(){
if(data=="Data"){
Serial1.println("Data");
//Serial.println("req data from slave");
delay(10);
delay(3);
if(Serial1.available() > 0){
Serial.println("AAAAgot data");
//Serial.println("AAAAgot data");
String data2 = Serial1.readStringUntil('\n');
Serial.print("Hi Raspberry Pi! You sent me: ");
Serial.println(String(data2));}
}

View File

@ -4,7 +4,6 @@ int i=0;
void setup() {
// put your setup code here, to run once:
Serial1.begin(9600);
Serial.begin(9600);
}
void loop() {
@ -13,10 +12,8 @@ void loop() {
if(Serial1.available() > 0) {
i+=1;
String data = Serial1.readStringUntil('\n');
Serial.print(data.charAt(0));
if(data.charAt(0)=='D'){ //this took forever to resolve, just do first char comparisions for now
Serial.println("true");
Serial1.print(myStr+"_");
Serial1.println(myStr2+i);

View File

@ -14,6 +14,6 @@ while (1):
i+=1
send_string = ("Data\n")
ser.write(send_string.encode('utf-8'))
time.sleep(0.02)
time.sleep(0.01)
receive_string = ser.readline().decode('utf-8').rstrip()
print(receive_string)

View File

@ -0,0 +1,13 @@
import socket
host='0.0.0.0'
port=2345
s=socket.socket()
s.bind((host,port))
s.listen(2)
while True:
conn,addr=s.accept()
print("Connected by",addr)
data=conn.recv(1024)
print("received data:",data)
conn.send(data)
conn.close()