• Category Archives Uncategorised
  • DS3231_Driver.h

    An example of a RTC driver based on the DS3231 RTC chip. The idea behind the driver is to replicate the chips register structure in part of the micro controller RAM memory in the form of a struct.

    /*
    Name		:	DS3231RTC_driver.ino
    Created		:	14-Jan-19 20:46:08
    Author		:	Oscar Goos
    Code		:	C++, Flash: 3944B, RAM: 413B
    Controller	:	ATmega328
    Last tested	:	14-Jan-2019
    Notes		:   Only Read Write Time and date registers implemented
    .			:	Copy DS3231 to RTC and the other way around could be done with a memcopy
    .			:	YinC must be uint16_t for both data sets
    .			:	Temperature not implemented
    */
    #include "ds3231_driver.h"
    RTC_t*	RTC;
    RTC_t	Timebuf={ 27, 20, 10, 6, 11, 12, 2019, 0 };
    DS3231	clock;
    
    void setup(void)
    {
    Serial.begin(115200);
    Wire.begin();
    //	RTC1.RTC = Timebuf;
    //	RTC1.Driver(INIT);
    delay(100);
    clock.Driver(SYNC);
    }
    
    void loop(void)
    {
    RTC1.Driver(SYNC);
    Serial.print(clock.RTC.sec); Serial.print("\t"), Serial.println(clock.RTC.SinD);
    delay(1000);
    
    }
    

    Here the C++ code of the library to be included in the code. It is the smallest and the simplest I have seen so far. The functions are called based on one class member with the name “Driver” and a command parameters tells the driver what to do. Three commands are implemented

    Sync: Copy time and date DS3231 registers to controller ram.
    INIT: Copy the RAM image to the DS3231 registers.
    TMDT2STR: Convert the RAM time and date registers to a time and date c-string.

    #ifndef		DS3231_H
    #define		DS3231_H
    
    #include	"wire.h"
    
    #define		INIT					0
    #define		SYNC					1
    #define		TMDT2STR				2
    
    #define		I2C_DS3231_ADR 			0x68
    #define		STOP					true
    
    #define		BCD2DEC(bcdval)			(((bcd_val>>4)*10) + (bcd_val & 0x0F))
    #define		DEC2BCD(decval)			(((dec_val/10)<<4) + (dec_val%10))
    
    typedef struct RTC_t {
    uint8_t						id;		// Struct identifier for future use
    uint8_t						sec;	// seconds,			00..59
    uint8_t						min;	// minuts,			00..59
    uint8_t						hr;		// hours,			00..23
    uint8_t						DinW;	// Day in week,		01..07
    uint8_t						DinM;	// Day in month,	01..31
    uint8_t						MinY;	// Month in year,	01..12
    uint16_t					year;	// Year				2000..2100
    uint32_t					SinD;	// seconds in day,	00..86399
    uint32_t					epoch;	// epoch time in sec since 1/1/1970
    int16_t						error;	// Time error in usec/sec
    char						tmstr[9] ="00:00:00";	// buffer for time string
    char						dtstr[11]="00/00/0000";	// buffer for date string
    } RTC_t;
    
    class DS3231 {
    
    typedef struct reg {
    uint8_t						sec;	// seconds,			00..59
    uint8_t						min;	// minuts,			00..59
    uint8_t						hr;		// hours,			00..23
    uint8_t						DinW;	// Day in week,		01..07
    uint8_t						DinM;	// Day in month,	01..31
    uint8_t						MinY;	// Month in year,	01..12
    uint8_t						YinC;	// Year in century,	00..99 respresenting 2000..2099)
    }__attribute__((packed, aligned(1))) reg_t;
    
    public:
    DS3231();
    RTC_t	RTC;
    void	Driver (uint8_t);
    
    private:
    reg_t	DSreg;
    
    protected:
    };
    
    DS3231::DS3231() {
    }
    
    void DS3231::Driver(uint8_t cmd) {
    
    uint8_t		n, bcd_val, dec_val;
    uint8_t*	DSptr = (uint8_t*)&DSreg;
    String		TDstr;
    
    switch (cmd) {
    case INIT: {
    DSreg.sec	= RTC.sec;
    DSreg.min	= RTC.min;
    DSreg.hr	= RTC.hr;
    DSreg.DinM	= RTC.DinM;
    DSreg.MinY	= RTC.MinY;
    DSreg.YinC	= RTC.year - 2000;
    DSreg.DinW	= RTC.DinW;
    RTC.SinD	= (uint32_t)RTC.hr * 3600 + (uint32_t)RTC.min * 60 + (uint32_t)RTC.sec;
    Wire.beginTransmission(I2C_DS3231_ADR);						// Start I2C and send Address
    Wire.write(0);													// set DS3231 register pointer to 0
    for (n = 0; n < sizeof(DSreg); n++) {
    dec_val = *DSptr++;											// Read nth data element from DS3231
    Wire.write(DEC2BCD(dec_val));								// Convert nth element dec2bcd and set all 7 RTC  Time date registers
    }
    Wire.endTransmission();											// Send I2C STOP and release the bus
    } break;
    
    case SYNC: {
    Wire.beginTransmission(I2C_DS3231_ADR);							// Start I2C and send Address
    Wire.write(0);													// set RTC  register address pointer to 0
    Wire.endTransmission();
    Wire.requestFrom((uint8_t)I2C_DS3231_ADR, (uint8_t)sizeof(DSreg),(uint8_t)STOP);
    for (n = 0; n < sizeof(DSreg); n++) {
    bcd_val = Wire.read();
    *DSptr++ = BCD2DEC(bcd_val);									// Read all 7 RTC  registers, convert bcd2dec in
    }
    RTC.sec		= DSreg.sec;
    RTC.min		= DSreg.min;
    RTC.hr		= DSreg.hr;
    RTC.DinM	= DSreg.DinM;
    RTC.MinY	= DSreg.MinY;
    RTC.year	= DSreg.YinC + 2000;
    RTC.DinW	= DSreg.DinW;
    RTC.SinD = (uint32_t)RTC.hr * 3600 + (uint32_t)RTC.min * 60 + (uint32_t)RTC.sec;
    DS3231::Driver(TMDT2STR);
    } break;
    
    case TMDT2STR: {
    TDstr = "";
    if (RTC.hr <= 9) TDstr += F("0");
    TDstr += String(RTC.hr);
    TDstr += F(":");
    if (RTC.min <= 9) TDstr += F("0");
    TDstr += String(RTC.min);
    TDstr += F(":");
    if (RTC.sec <= 9) TDstr += F("0");
    TDstr += String(RTC.sec);
    //		tmstr=(char*)TDstr.c_str();
    strcpy(RTC.tmstr, TDstr.c_str());
    
    TDstr = "";
    if (RTC.DinM <= 9) TDstr += F("0");
    TDstr += String(RTC.DinM);
    TDstr += F("/");
    if (RTC.MinY <= 9) TDstr += F("0");
    TDstr += String(RTC.MinY);
    TDstr += F("/");
    if (RTC.year <= 9) TDstr += F("0");
    TDstr += String(RTC.year-2000);
    //		dTDstr= (char*)TDstr.c_str();
    strcpy(RTC.dtstr, TDstr.c_str());
    } break;
    
    }
    
    }
    #endif // !DS3231_H
    

    Code is free for use.


  • Medidor de electricidad inteligente para los hogares mexicanos.


    TTS: Puedes escuchar esta pagina
    E-Meter front face Fig 1 : El medidor tal como es.
    E-Meter side face Fig 2 : El medidor desde un lado.
    The total package Fig 3 : El paquete

    Manual de usuario: “PDF Link a documento” tres lenguas: es,en,nl.
    Diptico de producto: “PDF Link a documento” una lengua: es.

    Introducción.

    Si lo que necesitas es conocer la cantidad de electricidad que es utilizada, o qué tan estable es su red de electricidad, este medidor es la solución. Con este medidor inteligente no tendrá más preguntas acerca de qué y cuánto electricidad que consume.
    Este medidor es inteligente porque le dice cuatro cosas por el precio de uno. Le dice su:

    • Uso de electricidad (kWh).
    • Energía eléctrica (W).
    • Voltaje (V).
    • Corriente (A).

    Hecho por HOLaMEX y “culumus de Ideas”.

    Este producto ha sido desarrollado en cooperación con HolaMex y Culumus. Holamex es una empresa holandesa-mexicana especializada en soluciones inteligentes de energía para los hogares y la industria. Cumulus es un buró de diseño gráfico ubicado en Querétaro (El Pueblito) y es responsable del estilismo producto.

    Ambas compañías colaboraron y desarrollaron un producto que da a la gente en México más control sobre su gasto de electricidad. En donde todos salen ganandoLo que obtiene y que es el costo.

    Lo que obtiene y que es el costo?

    Este medidor está a la venta en volúmenes limitados por el precio de 750 pesos mexicanos.
    Por este precio que se obtiene:

    • El medidor
    • Un manual de instalación y de usuario.
    • Los materiales de instalación.

    No se necesitan materiales adicionales para instalar aparte de un taladro y un destornillador. Todo está empaquetado en una caja de cartón fuerte.

    Como ordenar

    Este medidor está disponible en volúmenes limitados. Puede pedirlo enviando un correo electrónico en: info@holamex.nl usando su programa de correo electrónico o activar el enlace “estoy interesado en este medidor” y enviar una solicitud para comprar o necesita información adicional de est medidor.

    Pricing and Services

    El costo del medidor y los servicios adicionales es el siguiente.

    Monitor de electricidad servicios y costos
    Nr Services cost
    1 Paquete de medidor estándar $750,-
    3 Trabajo de instalación del medidor $500,-
    2 Ingeniería de paneles para medidores $ Quote
    4 Análisis del costo del consumo de energía $ 500,-
    Table1:2

    Especificación técnica de medidor de energía

    Las especificaciones del medidor se muestran en la tabla 2: 2 a continuación.

    Especificaciones de Medidor
    Group Characteristic value Unit
    Device Type HMPM-061
    Protectionc Class Indoor use
    Electric Voltage 80..260 [V]
    Current 0..100 [A]
    Frequency 45..65 [Hz]
    Display Type LCD
    Backlight Yes
    Parameter mon Voltage 0..260 [V]
    Current 0..100 [A]
    Power 0…22000 [W]
    Energy 0…9999 [KWh]
    Network 1- Phase, 2Wires Fase and neutral
    User interface Alarm Flashing Display
    Push button Reset energy value
    Pwr supply Internal / expernal Internal
    Tabel 1:1

  • User Manual: Backup power wall

    Introduction

    The backup power wall exists out of three main parts. These are

    • The 12Vdc/120Vac inverter
    • The battery charger
    • The battery
    • The casing with frond panel

    The 12V/120Vac inverter module is responsible to convert your 12Vdc battery voltage to 120Vac, the last one is needed within your house.
    The build in battery charger recharges you batteries automatic after you have had a power blackout.
    The battery uses is a special lead acid battery. We recommend not to use standard car batteries these are not made for backup applications.
    The front panel contain three switches, two power meters two fuses and two general purpose outlets. The front panel informs you about the state of the backup.

    How to install

    At the back panel or the backup you find a black cable with four wires. One green, One white, One red and One black wire. This cable is to be connected to a dedicated Fuse box with inside the same colors as the cable has. The fuse box is connected to the distribution panel of the house. The fuse box is needed in case the power wall needs to be disconnected from the grid. The disconnect is made on the fuse box not on the distribution panels of the house.
    The different colors have the following functions:

    • Green: Earth (G)
    • White: Neutral (N)
    • Red: Line from the street (L-street)
    • Black: Line going into the house L-house

    Make sure the distribution box is wired with the correct color’s. If you have doubts connect the fuse box but not the backup and call us or a qualified installer. If your not sure there is a serious risk of damage.

    How to use stand-alone

    If you use the backup as a stand-alone backup you don’t need to use the fuse box. A normal 120Vac connector needs to be installed on the black cable coming out of the back of the backup. The following wire as are used for this

    • Green: Earth (G)
    • White: Neutral (N)
    • Red: Line from the street (L-street)

    Cutoff or isolate the black unused wire. The installed connector can be plugged in to a standard wall socket. This allows the batteries to be recharged after a blackout.
    In stand-alone mode the back connector doesn’t have to be connected to a wall socket in order to use the front outlets.
    The frond outlets can be used to power your appliances like lights, TV, small drill at any time at any place.
    Recharging the battery requires the back cable to be connected with a 120vac wall socket.

    How to operate

    Ones the backup power wall is installed the backup is ready for operations. There are two mode of operations which are called cold and hot standby. Te two modes are selected with the small on/off switch located on the front of the inverter. The two modes are individual discussed.

    Cold Standby mode

    Cold standby means the backup battery charger is active but the electronics to convert the 12Vdc to 120Vac is off. This part of the electronics consumes about 8 Watts and is better to be switched of when there is no power failure expected. In this mode to power consumption of the inverter is about about 4 Watts. The fan is most of the time of but can switch on for 30 seconds.

    Hot Standby mode

    Hot standby means the backup battery charger is active but the electronics to convert the 12Vdc to 120Vac is also on. The inverter consumes now about 12Watts and is ready for coming into action when needed. This mode is selected when you think there might be a reason for power failure. The depending on the ambient temperature the fan is intermittent switching on.

    Use of the switches

    There are three large red toggle switches on the front plate of the backup and a smaller switch located at the on top located inverter. It is not possible to damage the backup by using the switches in what ever combinations, every on off combination is allowed. From top to bottom these switches have the following functions:

    • Inverter : on/off switch, switches between Holt/Colds standby of the 12Vdc/12Vac inverter unit
    • Front Top : on/off switch, Connects or disconnects the input side of the backup from the grid
    • Front Mid : on/off switch, Connects or disconnects the output to the backup
    • Front Bottom : toggle switch, between battery charge or discharge power meter readings.

    The bottom toggle switch allows to use the DC power meter for reading power in either charge mode or in discharge mode. The meter can not automatic switch between charge and discharge readings this needs to be done manually.

    Reading the power meters

    There are two power meters installed on the backup. The top power meter is a AC meter which measures the total power going out of the backup into your connected appliances. The meter below is a DC meter measuring the total power going in or out of the battery depending the battery is charging or discharging. To read the current and power of the bottom DC meter put the toggle switch in the right position.
    The following values are read from the AC and DC meter

    • Voltage in [V]olt
    • Current in [A]mpere
    • Power in [W]att
    • Energy in [Wh] Watt-hour

    There is a small button on each of the meters to reset the Watt-hour readings to zero. The procedure to reset the meters to zero is slight different between the two meters.
    To reset the meters do the following:
    AC meter at the top: Press the button for about 5 seconds till there is one message “PRS CLR” on the display and release the button. The Watt-hour reading is blinking now. Press the button again and the value resets to zero.
    DC meter at the bottom: Press the button for about 5 seconds till there is only one message “CLR” on the display and release the button. The Watt-hour reading is blinking now. Press the button again and the value resets to zero.

    Fuses and their function

    At the right bottom side are two locations for fuses. the backup is fused on the line input and line output side with each 10Amp. If the group of the house consume more than a 1200Whr these fuses will like break first and need to be replaced. The fuse types used are glass 6 x 30mm 10A fuses. Its handy to have a few spare of them.

    Estimate the backup time

    The backup time you have is the time the backup can produce electricity during a blackout. How long this time is depends on how much energy you consume per unit of time out of the battery. We can estimate the time by the the following Calculations
    Backup Time: Tb = battery capacity [Wh] / total power [Watt]
    The battery capacity can be read from the battery the power wall has a value of 900Wh,
    Example of the total power consumption is the power of a 40″ LED television + internet modem + 2xCFL lights + the capacity of the backup its self = 40Watt + 8Watt + 2*14Watt + 13Watt= 89Watt
    The time is calculated as follows Backup Time: Tb = Battery capacity [Wh] / Total power [Watt] = 900 / 89 = 10 hour.
    If the battery is not full the backup time is shorter. If more power is consumed than this example the backup time is shorter.

    Other things to know

    Not more than 360Watts.

    It is not recommended to load the system with a total power higher than 360Watts for several reasons. The Battery life time get shorter if the load increases. The battery capacity get lower if it is loaded with a high load. High loads lower your backup time. A high load will not damage the system it will lower its life time.

    More backup time

    It is possible to increase the backup time by adding a second 900Wh battery to the existing backup power wall.

    Switch off the inverter

    If you don’t expect an power outage it is recommended to switch of the inverter and go in cold standby mode. Battery charging will continue till the battery is full. See section How to operate

    Check the battery power meter

    If the inverter goes into backup mode reset the battery DC power meter. Set the toggle switch in right position. Check every now and then what the battery voltage [V] is and what the used capacity is in [Wh]. The battery voltage should never go below 10.5V. When the power indication goes from 0 up to 900Wh your battery is practically empty and the voltage will be around 10.5V. When you reach this point you must switch of the system because your ran out of backup time.


  • Vrij zinnige denkers zijn niet zo vrij al ze pretenderen te zijn.

    Een artiekel naar aanleiding van een Q&A vraag en antwoord  met een van de moderators van “Vrij zinnige denkers”.  Ik meen dit te moeten publiceren omdat als je jezelf “Vrij Zinnige Denkers” noemt hier ook een zeker gedrag bij hoort. Ik hoop dat dit binnen de moderators van deze groep een inhoudelijke discussie teweeg brengt die zowel ten goede komt aan de moderators als te meer aan de leden. hier volgt de het Vraag en antwoord schrijven tussen mij en een van de moderators.

    Q:

    Beste Moderators,
    Ik heb recentelijk een bericht/Pol over Thorium geplaatst, deze is niet verschenen. Is daar een reden voor of zit het nog in de pijplijn.

    A:

    Probeer het nog eens. Het moet wel voor iedereen te begrijpen zijn. Discussies over hele specifieke zaken waar specifieke kennis voor nodig is zijn niet interessant voor de groep.

    Q:

    ha ha ?? probeer het nog eens das geen antwoord op de vraag. De vraag is waarom het niet verschenen is. De vraag of het interessant is hoop ik toch echt dat dit niet beoordeeld wordt door moderators. Bovendien verondersteld het dat jullie als moderators op basis van jullie eigen kennis kunnen beoordelen wat interessant is of niet das helemaal bedenkelijk. Graag een antwoord op de vraag wat er is gebeurd met die post.

    A:

    Je post is niet geplaatst, dat is wat er mee gebeurd is.
    En daar kunnen heel veel redenen voor zijn…;
    -Of het bijgaande intro / vraagstelling was vaag of warrig of stond vol met kromme zinnen.
    -Of een soortgelijk artikel was al eerder geplaatst .
    Of de bron van het artikel was dermate twijfelachtig dat we niet het risico wilden lopen om fake nieuws te verspreiden .
    – Of iemand komt altijd aanzetten met het zelfde stokpaardje en we hadden er even geen zin meer in.
    – Etc etc etc… Er zijn nog veel meer redenen waarom een artikeltje niet geschikt kan worden bevonden.
    Maar doorgaans plaatsen we alles wat interessant lijkt voor onze lezersgroep en waar een duidelijke en korte en bondige inleiding van een paar zinnen bij staat
    Ik denk overigens dat we een regel toe gaan voegen aan de groepsregels ..;
    “Over het niet plaatsen van een artikel wordt niet gecorrespondeerd” .
    De leden kunnen namelijk absoluut niet zien wat wij als admins wel kunnen zien.
    Wij maken onze beslissingen ook echt niet gebaseerd op willekeur en natte vingerwerk.
    Mensen moeten maar een béétje vertrouwen in ons hebben wat dat betreft.
    Een leuk en goed artikeltje/ onderwerp wordt namelijk echt wel geplaatst, mits het zelfde artikel/onderwerp niet al eerder is geplaatst bij ons in de groep
    Maar de inzender heeft per definitie nou eenmaal niet de zelfde info als de admins, en dus moet men er maar gewoon op vertrouwen dat ook wij belang hebben bij het plaatsen van leuke, relevante artikeltjes en stukjes die een bijdrage leveren aan de discussies en gesprekken in onze groep.
    Q:

    Jammer weer geen antwoord. Ik voeg specifiek om waarom dat artiekel over thorium niet is geplaatst. Dat het niet geplaatst was dat wist ik al. Jullie hechten waarde aan goede zinnen wel nu, een antwoord op de vraag waarom het niet geplaatst is begint in goed ABN met: Het artiekel over thorium is niet geplaatst omdat……omdat het niet geplaatst is!!!!!. een nog al bedenkelijk antwoord niet.

    Jullie schreven “Het moet wel voor iedereen te begrijpen zijn. Discussies over hele specifieke zaken waar specifieke kennis voor nodig is zijn niet interessant voor de groep.” Jullie zijn moderators die je volgens mij helemaal niet moeten bezighouden met de vraag wat door anderen wel of niet begrepen kunnen worden en wat wel of niet zinnig is voor de groep. Mark zuckerberg is daarnet over ondervraagd in het US congress mochten jullie het gezien hebben. Mochten jullie als moderator dan toch besluiten een artikel niet te plaatsen dan is het toch allerminst gepast om een korte verklaring te sturen naar de schrijver in de trant van “Helaas hebben we uw artiekel niet kunnen plaatsten de reden hiervoor is: dubbel, slechte taal, lelijke woorden, beledigend, haat zaaiend, fake nieuws….. een kwestie van copy past en klaar, ik bedenk maar wat.

    Jullie tweede antwoord is een algemeen verhaal en ten tweede male geen antwoord op de gestelde vraag waarom jullie het artikel over thorium niet hebben geplaatst. Verder komt jullie algemeen verhaal niet overeen met de realiteit van je site. Veel onderwerpen zijn dubbel en is dan blijkbaar geen probleem. Eveneens zijn de zinnen lang niet altijd in goed ABN, Sommige poste hebben helemaal geen zin en bestaat uit een click paste. Verder zijn de antwoorden veel al niet in overeenstemming met de vraag of onderwerp van de post!!!!!. Verder geven jullie aan bang te zijn voor fake news, wat is is blijkbaar bij jullie als vrij zinnige denkers geen probleem en wordt bepaald door een moderator. Het lijkt waarachtig Brussel wel.

    Waar het over ging:

    Het onderwerp ging over de vraag wie weet wat een thorium centrale is, het was gesteld in de vorm van een poll en had tot doel een discussie op gang te brengen over wat het kan en beter kan doen t.o.v Uranium tevens wou ik de onbekendheid  van deze oude techniek onder de aandacht brengen. Het kan namelijk als kernsplijtstof gebruikt worden en een oplossing zijn voor CO2 uitstoot. Als bijkomstigheid kan het eveneens bestaand kernafval producten verwerken van Uranium centrales. Blijkbaar is dat voor jullie niet interessant en wensen jullie dat het publiek hier niet van op de hoogte gesteld wordt. Dat laat overigens wel zien wat het type moderator is dat er bij jullie zitten. Mijn advies neem nog eens jullie regels en moderator onder de loep want volgens mij zijn die in de achtergrond nog al gekleurd en zeker niet zo vrij denkend als ze pretenderen te zijn.
    Afrondend: Mochten Jullie mijn artiekel over thorium gebaseerde energie opwekking als nog niet willen plaatsten zonder een duidelijke reden daartoe dan blijft er niets anders over dan mij uit de groep te verwijderen. Ik wil niet gecensureerd worden door moderators die pretenderen vrije zinnige denkers te zijn en tegelijkertijd menen voor anderen te weten wat ze kunnen begrijpen en wat wel of niet zinnig voor hen is om over te debatteren. Met dank voor de periode dat ik van deze site gebruik heb mogen maken.