Forum Replies Created

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • tpapas
    Participant

      const char* arrayOfEmail[] = {“email1@gmail.com”, “email2@gmail.com”, “email3@gmail.com”};
      EMailSender::Response resp = emailSend.send(arrayOfEmail, 3, message);

      That did Renzo, I guess I could do that myself!!!

      Thank you so much for helping me in this project, I couldn’t have done it without your support!

      🙂

      tpapas
      Participant

        Renzo… Amazing! It does it now, it works like a charm…

        I thought that the line // Ethernet.begin(mac, ip, myDns, gateway, subnet); was a comment and didn’t realize that it was commented out code! (Stupid me)…

        Everything is perfect now, so all it needs now in order for me to close it is to email to 3 (or more recipients)

        And I will let you be after that 🙂

        tpapas
        Participant

          From a little further debugging that I did, on the matter of not sending an email if temperature goes above 30 degrees.

          // Check if value > 30 and check if you already send this email
          if (sensors.getTempCByIndex(0) > 30 && emailSended == false){
          emailSended = true;

           // if sendEmail() is here then email is sent ok

          // check if you had already send an email in the last 5 minutes
          if ((timeElapsed+EMAIL_SEND_DEBOUNCE)<millis()){
          timeElapsed = millis();
          Serial.print(F(“Trying to Send EMAIL NOW”));
          sendEmail();
          }
          }else{
          // The value return ok and so if you are going over 30 again new notification was sended
          emailSended = false;
          }

          So something is not working either with timeElapsed or emailSended.

          By the way how do I raise the timeElapsed from 5 minutes to 15 minutes?

          tpapas
          Participant

            Renzo… You are amazing!!!

            Thank you so much for the effort.
            I need some further help please.
            The server now as you have it, works by DHCP and since I need to publish it on the web it does need to be on a specific static IP so I can open the port on the router etc, so the server must be on 192.168.1.45

            Now when I ran it, the server started on 192.168.1.235.

            I don’t understand what these do (since I set them correctly but it didn’t use them):

            // Here we setup the web server. We are using a static ip address and a mac address
            byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

            IPAddress ip(192, 168, 1, 45);
            IPAddress myDns(192, 168, 1, 5);
            IPAddress gateway(192, 168, 1, 5);
            IPAddress subnet(255, 255, 255, 0);

            Also, I raised the (sensors.getTempCByIndex(0) > 30 and it didn’t send an email, and since there is no monitor debug output or anything, I don’t know if it did anything, but I didn’t get an email! (I did change all the credentials and API keys to mine).

            And one last thing, when we figure all this out and it works fine, I need it to send the same email to 3 recipients.

            Thank you

            tpapas
            Participant

              Renzo…
              I fixed it!!!!!!!!!!

              Hahaha, I’m excited for this! After lots of research, here’s the solution (FYI):
              <h2 id=”wiring-bme280-module-to-arduino-uno”>Wiring BME280 Module to Arduino UNO</h2>
              Let’s hook the BME280 module up to the Arduino.

              Connections are fairly simple. Start by connecting VIN pin to the 5V output on the Arduino and connect GND to ground.

              Now we are remaining with the pins that are used for I2C communication. Note that each Arduino Board has different I2C pins which should be connected accordingly. On the Arduino boards with the R3 layout, the SDA (data line) and SCL (clock line) are on the pin headers close to the AREF pin. They are also known as A5 (SCL) and A4 (SDA).

              If you have a Mega, the pins are different! You’ll want to use digital 21 (SCL) and 20 (SDA). Refer below table for quick understanding.

              SCL SDA
              Arduino Uno A5 A4
              Arduino Nano A5 A4
              Arduino Mega 21 20
              Leonardo/Micro 3 2

               

              Do you see it?! I was connecting the bme280 on A5 and A4 and it wanted it on 21 and 20!

              So now that this is over and all is ok, I need a favor from you 🙂 since I don’t know how to do it…

              You have the code, so in the code we get a mac address and we assign a static IP to the Ethernet shield.
              I need you to modify your email sending code, to work with the static IP, place it within the weather station code and then make it (with an IF statement) to send an email IF sensors.getTempCByIndex(0) > 30 degrees.

              Am I asking too much?!

              </div>

              tpapas
              Participant

                I will check, but remember it ran fine with your email routine! So I’m assuming that the shield is working properly.

                tpapas
                Participant

                  Thank you Renzo, sorry for the off topic!

                  I tried again and again, and its so strange, as soon as I compile the sketch on the UNO it works right away, on the MEGA it just doesn’t… And I can’t really tell where it stops (if it stops) if it loads in the EEPROM or if it wants to run and it stops somewhere etc… I m in total darkness, I can’t debug.

                  Anyway, if you need the cactus library, you can get it from here: http://cactus.io/projects/weather/arduino-weather-station-bme280-sensor

                   

                  tpapas
                  Participant

                    Renzo, good morning and a good week to you my friend.
                    You ‘re asking me what kind of problem do I have, it doesn’t work anymore!
                    On the UNO the code I will share with you works fine, it’s a webserver Weather Station that produces an HTML page with all the different measures, on a static IP.

                    Now on the Mega, no page loads, no output whatsoever, nothing!

                    Try it yourself (if you can/want/have the time) and let me know.

                    Here’s the code:

                    
                    #include <SPI.h>
                    #include <Ethernet.h>
                    #include <OneWire.h>
                    #include <DallasTemperature.h>
                    #include "TimerOne.h"
                    #include <math.h>
                    #include "cactus_io_BME280_I2C.h"
                    
                    #define TX_Pin 8 // used to indicate web data tx
                    // Data wire is plugged into digital pin 9 on the Arduino
                    #define ONE_WIRE_BUS 9
                    #define WindSensor_Pin (2) // digital pin for wind speed sensor
                    #define WindVane_Pin (A2) // analog pin for wind direction sensor
                    #define VaneOffset 0 // define the offset for caclulating wind direction
                    
                    volatile unsigned int timerCount; // used to count ticks for 2.5sec timer count
                    volatile unsigned long rotations; // cup rotation counter for wind speed calcs
                    volatile unsigned long contactBounceTime; // timer to avoid contact bounce in wind speed sensor
                    
                    volatile float windSpeed;
                    int vaneValue; // raw analog value from wind vane
                    int vaneDirection; // translated 0 - 360 wind direction
                    int calDirection; // calibrated direction after offset applied
                    int lastDirValue; // last recorded direction value
                    
                    int deviceCount = 0; // how many DS18B20 we keep on the OneWire
                    
                    float OutminTemp; // keep track of minimum recorded Outside temp
                    float OutmaxTemp; // keep track of maximum recorded Outside temp
                    float InminTemp; // keep track of minimum recorded Inside temp
                    float InmaxTemp; // keep track of maximum recorded Inside temp
                    
                    // Setup a oneWire instance to communicate with any OneWire device
                    OneWire oneWire(ONE_WIRE_BUS);
                    
                    // Pass oneWire reference to DallasTemperature library
                    DallasTemperature sensors(&oneWire);
                    
                    BME280_I2C bme; // I2C using address 0x77
                    
                    // Here we setup the web server. We are using a static ip address and a mac address
                    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
                    IPAddress ip(192, 168, 1, 45);
                    EthernetServer server(8081); // create a server listing on 192.168.1.45 port 80
                    
                    void setup() {
                    
                    // setup anemometer values
                    	lastDirValue = 0;
                    	rotations = 0;
                    
                    // setup timer values
                    	timerCount = 0;
                    
                    	{
                    		sensors.begin(); // Start up the library
                    		Serial.begin(9600);
                    // locate devices on the bus
                    // Serial.print("Locating devices...");
                    // Serial.print("Found ");
                    // deviceCount = sensors.getDeviceCount();
                    // Serial.print(deviceCount, DEC);
                    // Serial.println(" devices.");
                    // Serial.println("");
                    		sensors.requestTemperatures();
                    		InminTemp = sensors.getTempCByIndex(0);
                    		InmaxTemp = sensors.getTempCByIndex(0);
                    		OutminTemp = sensors.getTempCByIndex(1);
                    		OutmaxTemp = sensors.getTempCByIndex(1);
                    	}
                    
                    // disable the SD card by switching pin 4 High
                    	pinMode(4, OUTPUT);
                    	digitalWrite(4, HIGH);
                    
                    // start the Ethernet connection and server
                    	Ethernet.begin(mac, ip);
                    	server.begin();
                    
                    	if (!bme.begin()) {
                    // Serial.println("Could not find BME280 sensor, check wiring!");
                    		while (1)
                    			;
                    	}
                    
                    	pinMode(TX_Pin, OUTPUT);
                    //pinMode(RG11_Pin, INPUT);
                    	pinMode(WindSensor_Pin, INPUT);
                    	attachInterrupt(digitalPinToInterrupt(WindSensor_Pin), isr_rotation,
                    			FALLING);
                    
                    // setup the timer for 0.5 second
                    	Timer1.initialize(500000);
                    	Timer1.attachInterrupt(isr_timer);
                    
                    	sei(); // Enable Interrupts
                    }
                    
                    void loop() {
                    
                    // Send command to all the sensors for temperature conversion
                    	sensors.requestTemperatures();
                    
                    	bme.readSensor();
                    
                    // update min and max temp values for Outside and Inside Temperatures
                    	if (sensors.getTempCByIndex(1) < OutminTemp) {
                    		OutminTemp = sensors.getTempCByIndex(1);
                    	}
                    	if (sensors.getTempCByIndex(1) > OutmaxTemp) {
                    		OutmaxTemp = sensors.getTempCByIndex(1);
                    	}
                    
                    	if (sensors.getTempCByIndex(0) < InminTemp) {
                    		InminTemp = sensors.getTempCByIndex(0);
                    	}
                    	if (sensors.getTempCByIndex(0) > InmaxTemp) {
                    		InmaxTemp = sensors.getTempCByIndex(0);
                    	}
                    
                    // listen for incoming clients
                    	EthernetClient client = server.available();
                    	if (client) {
                    // an http request ends with a blank line
                    		boolean currentLineIsBlank = true;
                    		while (client.connected()) {
                    			if (client.available()) {
                    				char c = client.read();
                    				Serial.write(c);
                    // if you've gotten to the end of the line (received a newline
                    // character) and the line is blank, the http request has ended,
                    // so you can send a reply
                    				if (c == '\n' && currentLineIsBlank) {
                    // send a standard http response header
                    					digitalWrite(TX_Pin, HIGH);
                    					client.println("HTTP/1.1 200 OK");
                    					client.println("Content-Type: text/html");
                    					client.println("Connection: close"); // connection closed completion of response
                    					client.println("Refresh: 10"); // refresh the page automatically every 10 sec
                    					client.println();
                    					client.println("<!DOCTYPE HTML>");
                    					client.print(
                    							"<HTML><HEAD><TITLE>RadioActive Weather Server</TITLE></HEAD>");
                    					client.println(
                    							"<font color='red'><h2>RadioActive Weather Server</font></h2>");
                    					client.print(
                    							"Agios Merkouris, Sifnos @ 36.987832, 24.719809<br><br>");
                    					client.println("<html><body>");
                    					digitalWrite(TX_Pin, HIGH); // Turn the TX LED on
                    					client.print(
                    							"<span style=\"font-size: 26px\";>Outside Temperature now ");
                    					client.print(sensors.getTempCByIndex(1));
                    					client.println("C<br>");
                    					client.print("<br> Inside Temperature now ");
                    					client.print(sensors.getTempCByIndex(0));
                    					client.println("C<br>");
                    
                    					client.print("<br> Wind Speed now ");
                    					client.print(windSpeed);
                    					client.println(" mph<br>");
                    					getWindDirection();
                    					client.print("<br> Direction now ");
                    					client.print(calDirection);
                    					if ((calDirection) < 23) {
                    						client.print(" North");
                    					}
                    					if ((calDirection > 22) && (calDirection < 68)) {
                    						client.print(" NorthEast");
                    					}
                    					if ((calDirection > 67) && (calDirection < 113)) {
                    						client.print(" East");
                    					}
                    					if ((calDirection > 112) && (calDirection < 158)) {
                    						client.print(" SouthEast");
                    					}
                    					if ((calDirection > 157) && (calDirection < 203)) {
                    						client.print(" South");
                    					}
                    					if ((calDirection > 202) && (calDirection < 247)) {
                    						client.print(" SouthWest");
                    					}
                    					if ((calDirection > 246) && (calDirection < 292)) {
                    						client.print(" West");
                    					}
                    					if ((calDirection > 291) && (calDirection < 337)) {
                    						client.print(" NorthWest");
                    					}
                    					if ((calDirection > 336) && (calDirection <= 360)) {
                    						client.print(" North");
                    					}
                    					client.println("<br>");
                    					client.print("<br> Humidity now ");
                    					client.print(bme.getHumidity());
                    					client.println("%<br>");
                    					client.print("<br> Pressure now ");
                    					client.print(bme.getPressure_MB());
                    					client.println("mb%<br>");
                    					client.print("<br> Outside Min Temperature was ");
                    					client.print(OutminTemp);
                    					client.println("C<br>");
                    					client.print("<br> Outside Max Temperature was ");
                    					client.print(OutmaxTemp);
                    					client.println("C<br>");
                    					client.print("<br> Inside Min Temperature was ");
                    					client.print(InminTemp);
                    					client.println("C<br>");
                    					client.print("<br> Inside Max Temperature was ");
                    					client.print(InmaxTemp);
                    					client.println("C");
                    					client.println("</body></html>");
                    					digitalWrite(TX_Pin, LOW); // Turn the TX LED off
                    					break;
                    				}
                    				if (c == '\n') {
                    // you're starting a new line
                    					currentLineIsBlank = true;
                    				} else if (c != '\r') {
                    // you've gotten a character on the current line
                    					currentLineIsBlank = false;
                    				}
                    			}
                    		}
                    	}
                    
                    // give the web browser time to receive the data
                    	delay(1);
                    // close the connection:
                    	client.stop();
                    }
                    
                    // Interrupt handler routine for timer interrupt
                    void isr_timer() {
                    
                    	timerCount++;
                    
                    	if (timerCount == 5) {
                    // convert to mp/h using the formula V=P(2.25/T)
                    // V = P(2.25/2.5) = P * 0.9
                    		windSpeed = rotations * 0.9;
                    		rotations = 0;
                    		timerCount = 0;
                    	}
                    }
                    
                    // Interrupt handler routine to increment the rotation count for wind speed
                    void isr_rotation() {
                    
                    	if ((millis() - contactBounceTime) > 15) { // debounce the switch contact
                    		rotations++;
                    		contactBounceTime = millis();
                    	}
                    }
                    
                    // Get Wind Direction
                    void getWindDirection() {
                    
                    	vaneValue = analogRead(WindVane_Pin);
                    	vaneDirection = map(vaneValue, 0, 1023, 0, 360);
                    	calDirection = vaneDirection + VaneOffset;
                    
                    	if (calDirection > 360)
                    		calDirection = calDirection - 360;
                    
                    	if (calDirection > 360)
                    		calDirection = calDirection - 360;
                    }
                    
                    tpapas
                    Participant

                      Renzo, that I could follow and do easily, and yes it worked, I managed to do 3 recipients!

                      Now, another weird and upsetting problem occurred though.
                      I stopped using the UNO and installed the MEGA (which is actually a clone – not original), the email app worked beautifully now with the extra recipients and all… BUT, the webserver app with the weather station, which (like I told you) is my main app isn’t working anymore!

                      So I’m drawing a blank, now, I don’t know what to do and why isn’t this thing working?!
                      I’m asking you maybe you have an idea, because you’re a working with all this Arduino stuff!

                      Could it be the clone board? Could it be some 47Ohm resistors that somebody told me that I should solder under the Ethernet shield’s ethernet plug?
                      No idea…

                      tpapas
                      Participant

                        How can I have multiple recipients now?

                        tpapas
                        Participant

                          Finally IT WORKED!!!!

                          235 Authentication successful
                          MAIL FROM: <tpapas@datamax.gr>
                          250 Sender address accepted
                          RCPT TO: <tpapas@datamax.gr>
                          250 Recipient address accepted
                          DATA:
                          354 Continue
                          Message end
                          250 Ok: queued as oPx9XH7JQ8uREgp8eyHDbg
                          221 See you later
                          Sending status:
                          1
                          0
                          Message sent!

                          tpapas
                          Participant

                            Renzo, this is the line in your code that sends the email:

                            EMailSender emailSend(“<YOUR-SENDGRID-API-KEY>”, “<YOUR-SENDGRID-PASSWD>”, “<FROM-EMAIL>”, “smtp.sendgrid.net”, 25);

                            In the first attachment Sendgrid asks which method, WEB Api or SMTP Relay, I choose SMTP relay.

                            In there you can create a NEW Api key, I already have another API key created elsewhere in Sendgrid, so I’m not sure which key to use!

                            Then (in your code), you’re saying <YOUR-SENDGRID-PASSWD>, which password is that? The one that I use to login to the Sendgrid site?

                            If you can please help me finish this, it’s so confusing! Can I give you a Teamviewer or Anydesk if you want and we can fix it together?

                             

                            Attachments:
                            You must be logged in to view attached files.
                            tpapas
                            Participant

                              Man, this is really a brain buster and frustrating!

                              I believe I’ve done everything created a sender, an API etc, trying the TELNET example and on the end it tells me :

                              550 The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements

                              And I have verified a sender identity… Why does it have to be so difficult?!

                              I don’t know what else to do!

                              tpapas
                              Participant

                                Renzo, I ‘ve asked you this before but you didn’t tell me… Do I need to convert my credentials to Base64 or your library does it automatically?

                                tpapas
                                Participant

                                  Well, I guess you were right Renzo!
                                  I got a Mega 2560 and re-compiled… This is what I get now:

                                  Starting!
                                  IP address 192.168.1.235
                                  ONLY ONE RECIPIENTmiltiple destination and attachments
                                  Insecure client:0
                                  220 SG ESMTP service ready at ismtpd0005p1lon1.sendgrid.net
                                  HELO mischianti:
                                  250 Hello, nice to meet you
                                  AUTH LOGIN:
                                  334 VXNlcm5hbWU6
                                  Encoding
                                  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
                                  69
                                  U0cuQjVuREU3VHhSRnVRN2VRZDZMRXdtZy5NenBfdzgyWVF2blRDMnI1ZVMzbGd5b0xQNTd6VlZnMzhfMENvdkxxWWZR
                                  Encoding
                                  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
                                  69
                                  334 UGFzc3dvcmQ6
                                  Encoding
                                  9VPtvGtxr,H2q!j-
                                  16
                                  OVZQdHZHdHhyLEgycSFqLQ==
                                  Encoding
                                  9VPtvGtxr,H2q!j-
                                  16
                                  535 Authentication failed: Bad username / password
                                  Sending status:
                                  0
                                  235
                                  SMTP AUTH error (535 Authentication failed: Bad username / password )

                                  But my credentials are correct, since I got them directly from the sendgrid site. What am I doing wrong can you help me please?!

                                Viewing 15 posts - 1 through 15 (of 25 total)