Thursday, August 4, 2016

ESP Basic -3 - PCF8574 I2C I/O 8 x independent switches example



8 x Independent switches driver Example :






  
   After doing last time the Mutually exclusive 8x Switch driver example, now is time for a 8 x independent switches implementation .


What we will need: 


      This is how is looking the setup on a breadboard, for a better visibility:





Software implementation:

Something to remember: 

  • PCF8574 can SINK but NOT SOURCE much current - 100uA only (it cannot output high, if you want). Look at the above example how is connected the LED for SINKING current.
  • Each of the 8 GPIOs have a minimum guaranteed sinking current of 10 mA per bit at 5 V.
  • Each pin needs its own limiting resistor to prevent damage to the device!! keep under 25mA/pin.
  • Maximum device limit sink current in about 80mA. If you need more, look after PCA8574 (200mA max sink current!)

For more details please take a look at the PCF8574 Datasheet


ESP8266 Basic code: 
let address = 32 'PCF8574 I2C Address

i2c.begin(address)
ss = 0 xor 255 'XOR - Bit masking for the desired I/O pins
i2c.write(ss)
i2c.end()
button "1", [1]
button "2", [2]
button "3", [3]
button "4", [4]
button "5", [5]
button "6", [6]
button "7", [7]
button "8", [8]
button "OFF", [9]
wait

[9]
i2c.begin(address)
ss = 0 xor 255 'XOR - Bit masking for the desired I/O pins
i2c.write(ss)
i2c.end()
wait

[1]
i2c.begin(address)
ss = ss xor 1   'XOR - Bit masking for the desired I/O pins
i2c.write(ss)
i2c.end()
wait

[2]
i2c.begin(address)
ss = ss xor 2
i2c.write(ss)
i2c.end()
wait

[3]
i2c.begin(address)
ss = ss xor 4
i2c.write(ss)
i2c.end()
wait

[4]
i2c.begin(address)
ss = ss xor 8
i2c.write(ss)
i2c.end()
wait

[5]
i2c.begin(address)
ss = ss xor 16
i2c.write(ss)
i2c.end()
wait

[6]
i2c.begin(address)
ss = ss xor 32
i2c.write(ss)
i2c.end()
wait

[7]
i2c.begin(address)
ss = ss xor 64
i2c.write(ss)
i2c.end()
wait

[8]
i2c.begin(address)
ss = ss xor 128
i2c.write(ss)
i2c.end()
wait

This is how is looking the interface in the Web Browser after running the above program:



PS: credit for the XOR Bit masking goes this time to Forlotto from the esp8266.com forum who posted quicker than me this elegant solution :)

24 comments:

forlotto said...

Thanks for the credit could not have done it as quickly and efficiently without your help. Thank you TrackerJ for the videos excellent work and quality products that introduced me to you. I look forward to seeing some of the things that can be possible with basic with your great knowledge of hardware and quality components. You have shown me some large differences in quality while I admit I am sometimes skeptical I am not going to argue with a guy that has your years of experience as an Electronic Engineer. The AN1 is an interesting piece of hardware as well as your dimmer board and it appears to work with all esp based boards I prefer the espbasic implementation as it is more readable for the average user and a little less cumbersome to write with than LUA. But to each their own either can be made to be equally as effective.

Unknown said...

This is really a great post. Thank you for taking time to provide us some of the useful and exclusive information with us. Keep on blogging!!

Seo Training in Chennai

Unknown said...

This is really a great post. Thank you for taking time to provide us some of the useful and exclusive information with us. Keep on blogging!!

Seo Training in Chennai

Hema said...

This content creates a new hope and inspiration with in me. Thanks for sharing article like this. The way you have stated everything above is quite awesome. Keep blogging like this. Thanks.
Seo Web design company

Aurthur said...

Thanks for your informative article on digital marketing trends. I hardly stick with SEO techniques in boosting my online presence as its cost efficient and deliver long term results.
SEO Training in Chennai | SEO course in Chennai | SEO Training Institute in Chennai

Unknown said...

Great post!!Thank you for sharing this excellent blog of content.
Seo Course in Chennai | Seo Training in Chennai

Unknown said...

Thanks for taking time to share this information to my vision. It is really great and useful. Continue is sharing more like this.
Digital Marketing Training in Chennai | Digital Marketing course in Chennai | Digital Marketing Chennai

Melisa said...

Nice Post, keep blogging :)
Regards,
SEO Training Chennai|SEO Training in Chennai

charles said...

I was pinning away for such type of blogs, thanks for posting this for us.
Backlink

Roshni Kargi said...

Thanks for sharing this with us it is a worth read. xcellent post!!! Our Digital Marketing Course is tailored for beginners who want to learn how to stand out digitally, whether it is for their own business or a personal brand.

Digital Marketing Training in Chennai | Digital Marketing Course in Chennai | Digital Marketing Course | SEO Training in Chennai | Google Analytics Course | Social Media Marketing Course

Unknown said...

I’m really impressed with your article, such great & usefull knowledge you mentioned here.
Best institute chennai

Sanjay said...

Digital Marketing Intensive program in Chennai provides the best suppliers of SEO Training in Chennai with Search Engine Optimization Experts.
Seo training in Chennai

Anonymous said...

It is very nice blog to improve my knowledge in digital marketing. Thanks for sharing this awesome blog.
Digital Marketing Courses in Chennai | Digital marketing training institute in Chennai | Digital marketing course Chennai | Digital Marketing Training

gowthunan said...

Your new valuable key points imply much a person like me and extremely more to my office workers. With thanks; from every one of us.
iosh course in chennai

Raji said...

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
R Training Institute in Chennai | R Programming Training in Chennai

Hari K said...

Thanks for providing wonderful information with us. Thank you so much.

best java training institute in chennai
java j2ee training in chennai

Nisha San said...

Hey, would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would enjoy your content. Please let me know. Thank you.
Java Training in Chennai | J2EE Training in Chennai | Advanced Java Training in Chennai | Core Java Training in Chennai | Java Training institute in Chennai

Aruna said...

Your information's are really used to enhance my Knowledge...Came to learn lots of informative things from your site.Advance wishes for Upcoming posts...
Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

saran said...

"Thanks for sharing this information with us...
Digital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in Velachery

"

subathara said...
This comment has been removed by the author.
vanathi said...

Great post.I really liked you article,your writing style is simply awesome with useful informationSoftware Testing Training in Chennai

Software Testing Training in Velachery

Software Testing Training in Tambaram

Software Testing Training in Porur

Software Testing Training in Omr

Software Testing Training in Annanagar

subathara said...

This is really a great post. Thank you for taking time to provide us some of the useful and exclusive information with us. Keep on blogging!!
Digital Marketing Training in Chennai

Digital Marketing Training in Velachery

Digital Marketing Training in Tambaram

Digital Marketing Training in Porur

Digital Marketing Training in Omr

Digital Marketing Training in Annanagar


Lucereskin said...

Given article is very helpful and very useful.

SculpSure

Healthandfigure said...

Kya aap bhi aapne sex karni ki timing increase krna chhata hain toh aaj mein aap ko aise time badhane wale condom ke baare btaunga jiske istmaal se aap apni sex karni ki speed bada sakte hain aur kaafi lambe time tak sex kare skte hain

Post a Comment