Monday, April 24, 2017

ESPBasic - Web Interface - CSS elements example

A quick example on how to change your Web interface GUI objects properties without using a separate CSS file.

Reading Himidity and Temperature from a DHT22 Sesor connected to the GPIO5 and also retrieving Date and Time from NTP Server:

PinDHT = 5
DHT.SETUP(22, PinDHT)

cls

timer 1000, [branch] ' ## Time for auto refresh variables ##

wprint |<body style="background-color:powderblue;">|
wprint |<H1><span style="color: red;">|
wprint "Example for changing GUI object properties with CSS"
wprint "</H1>"
wprint "</span>"

wprint "<table border='1'><tr><td>Date</td><td>"
textbox Dtm
cssid htmlid(), "background-color: yellow;display:block;width:160px"
wprint "</td></tr><tr><td>Humidity </td><td>"
textbox Hum
cssid htmlid(), "background-color: grey;color:#F00;display:block;width:40px"
wprint "</td></tr><tr><td>Temperature Deg C</td><td>"
textbox Temp
cssid htmlid(), "background-color: #ccaabb;display:block;width:40px"

wprint "</td></tr></table><p>"

wprint "<p> Click to Exit <br>"
button "Exit", [TestExit]

Wait


[TestExit]
timer 0
end

[branch]
gosub [readdata]
wait

[readdata]
Dtm = time() 'Current Date and Time
Temp = DHT.TEMP() 'Current Temperature
Hum = DHT.HUM() 'Current Humidity


The result looks as below:






Friday, April 21, 2017

ESPBasic Series: Web Interface Slider demo


How easy or complicated is in ESPBasic to have a instant response slider for your MPDMv4 AC Dimmer Web interface?

Just look at the code below:
cls
let xpv = 0
let PWMpin = 5
slider x,150,900
timer 500, [set.dimmer]
wprint "<br><br>"
button " Exit ", [TestExit]

wait

[set.dimmer]
 if x <> xpv then
   io(pwo,PWMpin,x)
   xpv = x
 end if
wait

[TestExit]
wprint |<a href="./edit"> Edit</a>|
end

 Yes, it's all there, plus some extras :)

The Power of ESPBasic !

Friday, April 14, 2017

Part 2 - Raspberry Pi + Domoticz AC Dimmer


     ---------------------------------------------------------------------------------------------------------------------------

                       Special April Sale Discounts!!


Special Spring Sale discounts for all the products available on Tindie Store:
https://www.tindie.com/stores/nEXT_EVO1/

Including the popular MPDMv4 Universal AC Mains Dimmer and the MPRSx8 Home Automation Board!

Spread the word and use Coupon code: NDSCVO10

Thank you all for your support!

 ---------------------------------------------------------------------------------------------------------------------------


Part 2 of the tutorial: Raspberry Pi + Domoticz + MPDM v4 AC dimmer board.


Part 2 topic: Domoticz setup & final testing :





What we will need:

- MPDMv4 Universal AC Dimmer - available also on Tindie Store !
- Raspberry PI 2 Board

- PIGPIO library for Raspberry PI  - take a look at Part 1 how to install and test
- Domoticz
   Latest available, on a Raspberry PI 2 Board install :  
     sudo curl -L install.domoticz.com | bash



Software 

Domoticz LUA script for RPi Dimmer:

commandArray = {}
DomDevice = 'RPi_Dimmer';
if devicechanged[DomDevice] then
   if(devicechanged[DomDevice]=='Off') then
     print ("OFF dimm = "..uservariables['dimm']);
     CalcValue = 860*1000;
   else if(devicechanged[DomDevice]=='On') then
        DomValue = uservariables['dimm'];
        print ("ON dimm = "..uservariables['dimm']);
        CalcValue = DomValue;
      else
         print("Other");
         DomValue = otherdevices_svalues[DomDevice];
         CalcValue = (900-(DomValue*9))*1000;
         commandArray['Variable:dimm'] = tostring(CalcValue);
--         commandArray['Variable:dimm'] = CalcValue;
         print ("dimm Level = "..uservariables['dimm']);
   end
   end
   runcommand = "pigs hp 18 400 " ..tonumber(CalcValue);
   print("PWM calculated value= "..CalcValue);
   print("Run command: " ..runcommand);
   os.execute(runcommand);
end
return commandArray

 Save it as "script_device_RPi_Dimmer.lua" in the "domoticz/scripts/lua" folder !









--------------------------------------------------- DISCLAIMER --------------------------------------------------
WARNING!! You will play with LIVE MAINS!! Deadly zone!! 
      If you don't have any experience and are not qualified for working with MAINS power I will not encourage you to play arround!. The author take no responsibility for any injury or death resulting, directly or indirectly, from your inability to appreciate the hazards of household mains voltages.
   The circuit diagrams are as accurately as possible, but are offered with no guarantees whatsoever. 
    There is no guarantee that this design meets any Rules which may be in force in your country so please check before your local rules/regulations.
----------------------------------------------------------------------------------------------------------------------------
 
                                                             Creative Commons License

All materials and boards released under ESP8266-Projects.com are licensed under a Creative Commons Attribution-NonCommercial 4.0 International License 





Wednesday, April 5, 2017

Raspberry Pi + Domoticz AC Dimmer - Part 1


     ---------------------------------------------------------------------------------------------------------------------------

                       Special April Sale Discounts!!


Special Spring Sale discounts for all the products available on Tindie Store:
https://www.tindie.com/stores/nEXT_EVO1/

Including the popular MPDMv4 Universal AC Mains Dimmer and the MPRSx8 Home Automation Board!

Spread the word and use Coupon code: NDSCVO10

Thank you all for your support!

 ---------------------------------------------------------------------------------------------------------------------------



New Tutorial related with direct connection setup between Raspberry Pi board and MPDM v4 AC dimmer board.

Part 1: General view, wiring and hardware setup :



What we will need:

- MPDMv4 Universal AC Dimmer - available also on Tindie Store !
- Raspberry PI 2 Board
- Domoticz
   Latest available, on a Raspberry PI 2 Board install :  
     sudo curl -L install.domoticz.com | bash


 

Software 

1. PIGPIO library for Raspberry PI install script:
rm pigpio.zip
sudo rm -rf PIGPIO
wget abyz.co.uk/rpi/pigpio/pigpio.zip
unzip pigpio.zip
cd PIGPIO
make -j4
sudo make install
save it in the choosen directory for your PIGPIO library as "install.sh" and run also command:
chmod 775 install.sh

2. Testing script:
#!/usr/bin/env python

#*** MPDMv4 Universal AC Dimmer PWM Example  ****************
#*                                                          *
#* This demo is using RPi2 GPIO18 (header pin 12)!!         *
#*                                                          *
#* Wiring table:                                            *
#* MPDMv4      Raspberry PI 2                               *
#*   VCNT  ->  GPIO18      - header pin 12                  *
#*    GND  ->  GND         - header pin 6                   *
#*    VCC  ->  VCC (+3,3V) - header pin 1                   *
#*                                                          *
#* tech@esp8266-projects.com                                *
#*                                                          *
#************************************************************
 
import pigpio

GPIO=18

pi = pigpio.pi()

if pi.connected:
   print("Connected to pigpio daemon !\n")

dm = 0
while dm < 860:
    dm = input("Enter Dimmer Value: ")
    dm = int(dm)
    pi.hardware_PWM(GPIO, 5000, dm*1000) # 5000Hz dm*1000% dutycycle

print("\nOut of range. Exiting...")
pi.hardware_PWM(GPIO, 5000, 860000) # 5000Hz 95% dutycycle
pi.stop()


save it as "test.py" in the PIGPIO folder generated after the full install is done.


Next time: Domoticz setup & configuration and Dimmer testing.



--------------------------------------------------- DISCLAIMER --------------------------------------------------
WARNING!! You will play with LIVE MAINS!! Deadly zone!! 
      If you don't have any experience and are not qualified for working with MAINS power I will not encourage you to play arround!. The author take no responsibility for any injury or death resulting, directly or indirectly, from your inability to appreciate the hazards of household mains voltages.
   The circuit diagrams are as accurately as possible, but are offered with no guarantees whatsoever. 
    There is no guarantee that this design meets any Rules which may be in force in your country so please check before your local rules/regulations.
----------------------------------------------------------------------------------------------------------------------------
 
                                                             Creative Commons License

All materials and boards released under ESP8266-Projects.com are licensed under a Creative Commons Attribution-NonCommercial 4.0 International License 




Monday, April 3, 2017

Special Spring Sale Discounts!!



Special Spring Sale discounts for all the products available on Tindie Store:
https://www.tindie.com/stores/nEXT_EVO1/

Including the popular MPDMv4 Universal AC Mains Dimmer and the MPRSx8 Home Automation Board!

Spread the word and use Coupon code: NDSCVO10

Thank you all for your support!