Go Down

Topic: Serial Monitor showing garbage  (Read 225 times) previous topic - next topic

Garima_Mishra123

I have an arduino uno which is connected to a load cell and an esp8266 to create in the end a project which will send a notification when a specific weight is exceeded. Whenever i upload the my code the text I get in the serial monitor is just repeated : |?

The code I am using is:

#include <UnoWiFiDevEd.h>

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>

#include <HX711.h>


String deviceId = "v2B3F20B7DF9815A";
const char* logServer = "api.pushingbox.com";

const char* ssid = "Sarkaar_Wireless";
const char* password = "Garima3007$";

void setup()
{
    Serial.begin(74880);

  sendNotification("Hello World from ESP8266!");
}

void sendNotification(String message){

  Serial.println("- connecting to Home Router SID: " + String(ssid));
 
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
 
  Serial.println();
  Serial.println("- succesfully connected");
  Serial.println("- starting client");
 
  WiFiClient client;

  Serial.println("- connecting to pushing server: " + String(logServer));
  if (client.connect(logServer, 80)) {
    Serial.println("- succesfully connected");
   
    String postStr = "devid=";
    postStr += String(deviceId);
    postStr += "&message_parameter=";
    postStr += String(message);
    postStr += "\r\n\r\n";
   
    Serial.println("- sending data...");
   
    client.print("POST /pushingbox HTTP/1.1\n");
    client.print("Host: api.pushingbox.com\n");
    client.print("Connection: close\n");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(postStr.length());
    client.print("\n\n");
    client.print(postStr);
  }
  client.stop();
  Serial.println("- stopping the client");
  Serial.begin(9600);
  pinMode(A1, INPUT);
  pinMode(A0, OUTPUT);
HX711 loadcell;

loadcell.set_scale();
loadcell.tare();
loadcell.get_units(10);
Serial.println(loadcell.get_units(10));
}

void loop()
{
HX711 loadcell;

const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;


const long LOADCELL_OFFSET = 50682624;
const long LOADCELL_DIVIDER = 5895655;


loadcell.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
loadcell.set_scale(LOADCELL_DIVIDER);
loadcell.set_offset(LOADCELL_OFFSET);

Serial.print("Weight: ");
Serial.println(loadcell.get_units(10), 2);

Any suggestions as to why I am getting garbage in the serial monitor and any wrong bits in my code?


blh64

You are starting Serial at a baud rate of 74880 which is not a standard value.  The Serial monitor must be set to match this baud rate if you hope to achieve communication between your Arduino and the PC.  There is a drop-down box in the bottom right corner of the Serial Monitor to set the buad rate

Garima_Mishra123

Thank you it seems to start running normally now. However after saying "connecting to home router SID" it just carries on printing "." any suggestions why.

blh64

Yes, this code
Code: [Select]
while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
tests the status of the connection every 500msec and prints out that "." so it seems you are not connecting to the wifi

Garima_Mishra123

Why am I not connecting though? Is there any code I need to add in order to connect?

pert

Why am I not connecting though? Is there any code I need to add in order to connect?
I've explained the problem in your other thread:
http://forum.arduino.cc/index.php?topic=611623.msg4147131#msg4147131

Go Up