Go Down

Topic: Programing help with temperature  (Read 709 times) previous topic - next topic

cattledog

Code: [Select]
debouncer.update(Startup_Pin)
debouncer.read(Startup_Pin)


This advice was incorrect. I was rushed, did not see your previous posting, and made an error.

In set up you have this
Code: [Select]
#include <Bounce2.h>
Bounce debouncer = Bounce();
debouncer.attach(Startup_Pin); //bouncing liquid level could trip it twice



Begin loop() with

debouncer.update() 
There is no need to specify the pin because the instance "debouncer" was attached to StartUp_Pin in setup()

Then, every time you want to know the value (state) of StartUp_Pin replace digitalRead(StartUp_Pin) with debouncer.read()

You can certainly assign the pin value to a variable like S_U_P = debouncer.read() and then use client.print(S_U_P)

tobielepine

The vacuum sender is on the vacuum source (well on my kitchen table right now) so A0 just floats for now.

The reason to use if machine is running is because it has to shut down at colder temps than it turns on at ...


I need help with my

Delay (5000000000000);

That delay forever works ok by the fact it saves a vacuum pump from sucking in liquid and wreck it. But while the arduino is stuck waiting forever. It doesnt update the website ... the site goes down and as such, any clue that the machine needs urgent attention if we are to make maple syrup.

What about

If (digitalread (safety_pin == LOW))
{
Shut off the vacuum;
Pump liquid out;
While (1)
}


How can i make it still update the website?

Thanks for all your help

cattledog

Quote
How can i make it still update the website?
You can put web notification in the while() loop.

Code: [Select]
If (digitalRead(safety_pin == LOW))
{
  //Shut off the vacuum;
  //Pump liquid out;
  while(1)
  {
    //send web nofication about safety shutdown
  }
}

tobielepine

The vacuum on A0 is unrelated to the bmp180.

It mesure differential pressure between the vacuum source and the atmospheric pressure.

The bmp180 is used to calibrate athmospheric pressure.

The vaccum runs about 20InHG of vacuum.

The fluctuations of the vacuum pressure value only make sence if you put them against atmospheric pressure.

How can i write (flushcounter) to eprom and always count up despite resets?


T


PaulS

Quote
How can i write (flushcounter) to eprom and always count up despite resets?
What have you tried? EEPROM.put() and EEPROM.get() do not require a PhD in computer science to use.
The art of getting good answers lies in asking good questions.

tobielepine


cattledog

Quote
Do i need eprom addr with that?
You will be using the internal eeprom and the EEPROM.h library. Please take a look at the library examples which come with EEPROM.h. That library is packaged with the IDE.

tobielepine

I cant make sense of the exMPLES


I don't want to start troubleshooting a working maching just yet.

I cannot understand why nobody can make an example that both reads and write to eeprom ...


pretty simple

I have :


int flushCounter = 0;   // counter for the number of  flushes


wont this indicate 0 everytime ?...


how do I make flushCounter data that is stored and read on the eprom.

I guess it has to write at the end of the loop and read at the beginning of it ?

or would it read during the setup?

does anybody have a working example of a COUNTER on EEPROM?

eeprom read and eeprom write are separate file and it might seem simple enough to combine but I cannot do it.



help please


T








tobielepine

Code: [Select]


/***
    eeprom_put example.

    This shows how to use the EEPROM.put() method.
    Also, this sketch will pre-set the EEPROM data for the
    example sketch eeprom_get.

    Note, unlike the single byte version EEPROM.write(),
    the put method will use update semantics. As in a byte
    will only be written to the EEPROM if the data is actually
    different.

    Written by Christopher Andrews 2015
    Released under MIT licence.
***/

#include <EEPROM.h>

struct MyObject {
  float field1;
  byte field2;
  char name[10];
};

void setup() {

  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  float f = 123.456f;  //Variable to store in EEPROM.
  int eeAddress = 0;   //Location we want the data to be put.


  //One simple call, with the address first and the object second.
  EEPROM.put(eeAddress, f);

  Serial.println("Written float data type!");

  /** Put is designed for use with custom structures also. **/

  //Data to store.
  MyObject customVar = {
    3.14f,
    65,
    "Working!"
  };

  eeAddress += sizeof(float); //Move address to the next byte after float 'f'.

  EEPROM.put(eeAddress, customVar);
  Serial.print("Written custom data type! \n\nView the example sketch eeprom_get to see how you can retrieve the values!");
}

void loop() {
  /* Empty loop */
}



what is a float ?

I don't want a float I want a counter that doesn't care about power off cycles?

can it be that hard?

I want to overwite a number between 1 and 1000 ... and count up everytime (startup_pin) goes low.

I don't want variable value location or any of that .... just store a number between 1 and 1000 and don't miss a beat.

thx

help please

T

cattledog

#39
Mar 20, 2017, 08:28 pm Last Edit: Mar 20, 2017, 08:32 pm by cattledog
Add the EEPROM.h library
Code: [Select]
#include "HCSR04.h"
#include <SPI.h>
#include <Ethernet.h>
#include <SFE_BMP180.h>
#include <Wire.h>
#include <Bounce2.h>
#include <EEPROM.h>


define an address where you want to store the flush count. The eeprom is specified for 100,000 writes, but in practice people get many many more. You may want to move this storage address every so often. There are ways to manage this automatically, but for now get started with a fixed address.

Code: [Select]
int flushCounter = 0;   // counter for the number of  flushes
int eeAddress = 0; // starting location in eeprom where flush count will be stored, the integer will occupy two bytes of storeage space, address0 and address1


Add to setup() this line which will place the stored value into the variable flushCounter
Code: [Select]
EEPROM.get(eeAddress, flushCounter);

This appears to be the section where flushCounter is incremented, so add the EEPROM.put() statement here.

Code: [Select]
if (switchState != lastswitchState) {
    // if the state has changed, increment the counter
    if (switchState == LOW) {
      // if the current state is low then the float
      // wend from off to on:
      flushCounter++;
      EEPROM.put(eeAddress, flushCounter);
      Serial.println("Flushing");
      Serial.print("number of  flushes:  ");
      Serial.println(flushCounter);
      Serial.println((flushCounter)*1);
    }


Quote
I want to overwite a number between 1 and 1000 ... and count up everytime (startup_pin) goes low.
I don't see where in the code you reset the flush counter if it hits 1000. If you need to do that, the right after  the line flushCounter++ you can add

Code: [Select]
if(flushCounter == 1000)
  flushCounter = 0;



tobielepine

Catteldog,

Thanks for pointing me in the right direction ..

The maple syrup we boiled tonight is some of the best ive tasted ... ill find a way to get a can your way.

I need eeprom.get int the setup, i understand that.

And store a new value to it in the loop ...

That makes my day ... and i dont even need a limit ... 1000 is quite arbitrary ...

But could i store a number such a 52853 like 5 digits?  Could i store multiple values? Like runtime (which is in the latest working version) ? What are the limits to a single address?
Can i store/display the last 10 (flushes) on a timetable?

Haha ill get to version 9 at some point.

If youve checked the website, it was at 99 flushes last time i checked.

Forget about flashing led's with arduinos... lets make maple syrup!

Btw, a mega 2650 and a uno are working right now, pulling maple sap and protecting expensive vaccums from liquid lock on 2 different projects.  For those who say they arent fit for industrial use, i beg to differ!

The internet of things is now ... 45 bucks got me started! And this forum!



T

cattledog

#41
Mar 21, 2017, 04:11 am Last Edit: Mar 21, 2017, 04:14 am by cattledog
Quote
If you've checked the website, it was at 99 flushes last time i checked.
Yes I have looked at the website, and the pattern of events does not always make sense to me.
Quote
version 5.1.1
number of flushes: 99
99 Gallons
bassin est/tank is: 13.70 % plein/full 32.79 CM du bord/from top
relative (sea-level) pressure: 1010.70 mb, 29.85 inHg
absolute pressure: 995.81 mb, 29.41 inHg
sensor altitude: 125 meters, 410 feet
temperature: 0.45 deg C, 32.81 deg F
0= empty level sensor. 0 if under water
1= pump trigger sensor. 0 if under water
1 = vacuum safety level sensor. 0 if under water
1= pump state 0 = On, 1 = Off
0= vacuum state: 0 = On, 1 = Off
vaccum 0 is -0.42 InHg
I think have seen the number of flushes change without the pump state, and visa versa. The level also confuses me because it can be over 100% without triggering pump activity. what is the volume of the volding tank? Is each flush really a gallon? Can you give a brief summary of
your inputs and outputs. I will review your code in more depth when you post the next version.

Quote
But could i store a number such a 52853 like 5 digits?  Could i store multiple values? Like runtime (which is in the latest working version) ? What are the limits to a single address?
Can i store/display the last 10 (flushes) on a timetable?
EEPROM.put() and EEPROM.get() can handle anything you want to throw at them :)
There are 1024 addresses in the eeprom. Each address will hold one byte. When you store multi byte data, the eeprom library knows how to place the data in multiple storage locations and get it from them. A number like 52853 would just be an unsigned integer (2 bytes). The eeprom is best used for information which you want to carry over between startups. For extensive data storage, you may want to look at an SD card, or figure out how to save information from the website application.

I am surprised that there is not an RTC (real time clock) module with the system. I would think that knowledge of the time would be important.

tobielepine

You need to understand the holding tank is made of SS and my ultrasonic sensor gives unreliable data as to its depth.

Because of the delays, you might not see the pump come on or the startup pin go high. The pump time is a few seconds and the refresh rate on the browser is longuer than that sometimes.

Im still afraid the counter goes up twice for a single emptying of the manigfold.

That one is an arduino uno with a network shield. Luckily connected to the world via internet . . (Wireless repeater bridge via ddwrt on a wrt54g2) sometimes i get 802.11b .... but most times it defaults to 802.11a because of packet loss ... so browser time to receive data and refresh rate had to go up.  This uno, i dont really care about.... i could use a internet connected computer to pull data off the web in an excel sheet and make sense of it.



The eeprom data is more useful on the one that resets 4-5 times/day because of power loss ... it lives off the grid with generators as power input. When they need fuel, i lose my 24h picture of maple production.  Its a 2650 with pressure and temperature off a bmp180.
1400 maples are connected to this system.

Same principleas the uno with the pump, but it uses 2 chambers and gravity to release vacuum collected sap ..

Quite complex but its part of an off-grid industry making maple syrup.

Hence some static memory need! It reset so often i need to check last data before the generator runs out of fuel, or i lose my efficiency/temperature data forever.

I hate the pad, paper and pen method.


T


cattledog

Quote
The eeprom data is more useful on the one that resets 4-5 times/day because of power loss ... it lives off the grid with generators as power input. When they need fuel, i lose my 24h picture of maple production.  Its a 2650 with pressure and temperature off a bmp180.
1400 maples are connected to this system.
The ATmega2560 has a 4096 byte (4K) eeprom. That should be plenty of storage.

Do you pull data from the mega which is off the grid? Is there a display? How do you plan to access the data that you store?

tobielepine

The 2650 off the grid has a w5100 shield with sd . and an old cisco wireless router connected to it. it runs off an old computer powersupply. the psu also powers the relay board that controls the solenoid valves.

I pull the data with my smartphone on the wifi.

storing to sd could be another option but I have difficulty making both the Ethernet and sd work at the same time.

im thinking I would just have to upload a EEPROM clear sketch once a year. and just let the data build.

the maple season is about 6-8weeks long ... the rest of the year, the arduinos, vaccums etc... are not used.


im trying a few things in my sketch.

I will upload the offgrid sketch shortly.


T

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy