issue107:arduino
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue107:arduino [2016/04/08 00:09] – erlevo | issue107:arduino [2016/04/08 14:49] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
**WARNING: This month we’re heading into the big league with controlling household voltage devices. It should go without saying, but I’ll say it anyway, you must make sure your 110/240V devices are unplugged before chopping cables, and double-check your wiring before you do put that plug back into the wall outlet.** | **WARNING: This month we’re heading into the big league with controlling household voltage devices. It should go without saying, but I’ll say it anyway, you must make sure your 110/240V devices are unplugged before chopping cables, and double-check your wiring before you do put that plug back into the wall outlet.** | ||
- | ATTENTION : ce mois-ci, nous passons en première division en pilotant des appareils sous tension domestique. Il va sans dire, mais je le dis quand même, que vous devez vous assurer que vos appareils sont débranchés avant de couper des câbles, et vérifier deux fois votre câblage avant de remettre la fiche dans la prise murale. | + | ATTENTION : ce mois-ci, nous passons en première division en pilotant des appareils sous tension domestique. Il va sans dire, mais je le dis quand même, que vous devez vous assurer que vos appareils sont débranchés avant de couper des câbles et vérifier deux fois votre câblage avant de remettre la fiche dans la prise murale. |
**In previous articles, I used an LCD screen which, while it worked, would need about a dozen wires and a potentiometer to control the screen brightness (see photo, top board). This time, I’ve managed to get some much simpler LCD screens that require only four wires (same photo, bottom board). The wires are VCC, GND, SDA and SCL. These should be marked on your Arduino, but on UNO boards, I believe it’s A4 and A5. On my MEGA, it’s 20 and 21 and they’re marked as such. But you need to put both those lines through a 4.7K resistor from 5V. | **In previous articles, I used an LCD screen which, while it worked, would need about a dozen wires and a potentiometer to control the screen brightness (see photo, top board). This time, I’ve managed to get some much simpler LCD screens that require only four wires (same photo, bottom board). The wires are VCC, GND, SDA and SCL. These should be marked on your Arduino, but on UNO boards, I believe it’s A4 and A5. On my MEGA, it’s 20 and 21 and they’re marked as such. But you need to put both those lines through a 4.7K resistor from 5V. | ||
Ligne 9: | Ligne 9: | ||
Before adding LCD code, we need to do a scan of the LCD screen to get its I2C address. Different models have different addresses. So, grab the code from: http:// | Before adding LCD code, we need to do a scan of the LCD screen to get its I2C address. Different models have different addresses. So, grab the code from: http:// | ||
- | Dans les articles précédents, | + | Dans les articles précédents, |
- | Ces nouveaux écrans LCD sont I2C ce qui signifie qu'ils ont une petite carte de pilotage au dos. Cela signifie aussi qu'ils besoin d'une nouvelle bibliothèque (https:// | + | Ces nouveaux écrans LCD sont I2C ce qui signifie qu'ils ont une petite carte de pilotage au dos. Cela signifie aussi qu' |
Avant d' | Avant d' | ||
Ligne 61: | Ligne 61: | ||
LiquidCrystal_I2C | LiquidCrystal_I2C | ||
- | Dans mon paramétrage, | + | Dans mon paramétrage, |
**lcd.begin (16, | **lcd.begin (16, | ||
Ligne 89: | Ligne 89: | ||
delay(2000); | delay(2000); | ||
- | La plupart de ces commandes | + | La plupart de ces commandes |
- | Maintenant, j'ai la température, | + | Maintenant, j'ai la température, |
**lcd.setCursor(0, | **lcd.setCursor(0, | ||
Ligne 123: | Ligne 123: | ||
Avant de couper le câble de ma chère couverture chauffante, je veux être sûr que le circuit fonctionne. Aussi, à la place, je vais sacrifier une lampe de bureau inutilisée. | Avant de couper le câble de ma chère couverture chauffante, je veux être sûr que le circuit fonctionne. Aussi, à la place, je vais sacrifier une lampe de bureau inutilisée. | ||
- | Après l' | + | Après l' |
**The solid state relay (SSR for short) has two DC inputs (in the photo, at the bottom left, is the red +5v and blue ground). It also has (depending on your SSR) one or more channels. My SSR has two channels. This is where your Arduino (yellow wire in the photo) will tell the SSR to go HIGH or LOW. The final two inputs are for the cable you wish to open/close. In this case the live (top wires in the photo) from my lamp. Now, it didn’t help that my inputs are labelled wrongly. The one marked ‘Ch1’ is actually for SSR channel two. So if you try this and it doesn’t work, try switching your wire from Ch1 to Ch2. You should see a light come on on the SSR to show which channel is HIGH/LOW. | **The solid state relay (SSR for short) has two DC inputs (in the photo, at the bottom left, is the red +5v and blue ground). It also has (depending on your SSR) one or more channels. My SSR has two channels. This is where your Arduino (yellow wire in the photo) will tell the SSR to go HIGH or LOW. The final two inputs are for the cable you wish to open/close. In this case the live (top wires in the photo) from my lamp. Now, it didn’t help that my inputs are labelled wrongly. The one marked ‘Ch1’ is actually for SSR channel two. So if you try this and it doesn’t work, try switching your wire from Ch1 to Ch2. You should see a light come on on the SSR to show which channel is HIGH/LOW. | ||
Ligne 141: | Ligne 141: | ||
Le relais statique (RS pour faire court) a deux entrées en courant continu (sur la photo, en bas à gauche, le +5V est rouge et la masse bleue). Il comporte aussi (suivant votre RS) un ou plusieurs canaux. Le mien en a deux. C'est par ici que votre Arduino (fil jaune sur la photo) alimentera ou non votre RS. Les deux dernières entrées sont pour le câble que vous souhaitez ouvrir/ | Le relais statique (RS pour faire court) a deux entrées en courant continu (sur la photo, en bas à gauche, le +5V est rouge et la masse bleue). Il comporte aussi (suivant votre RS) un ou plusieurs canaux. Le mien en a deux. C'est par ici que votre Arduino (fil jaune sur la photo) alimentera ou non votre RS. Les deux dernières entrées sont pour le câble que vous souhaitez ouvrir/ | ||
- | Une fois tout ceci en place, | + | Une fois tout ceci en place, le moment |
Pour tester le RS, je vais faire clignoter la lampe. Les premières nouvelles lignes de code sont : | Pour tester le RS, je vais faire clignoter la lampe. Les premières nouvelles lignes de code sont : | ||
Ligne 167: | Ligne 167: | ||
as this will be used in the if/then to switch on/off the lamp.** | as this will be used in the if/then to switch on/off the lamp.** | ||
- | Ceci définit le picot 53 de l' | + | Ceci définit le picot 53 de l' |
- | Je commence avec l' | + | Je commence avec l' |
pinMode(ssr1, | pinMode(ssr1, | ||
Ligne 191: | Ligne 191: | ||
With the interval set at 1000 this means the lamp will turn on/off every second.** | With the interval set at 1000 this means the lamp will turn on/off every second.** | ||
- | La seule addition notable de code est la commutation (en haut à droite). CurrentMillis et PreviousMillis conservent les durées en millisecondes de parcours de la boucle. Quand « interval » est atteint (fixé au début), | + | La seule addition notable de code est la commutation (en haut à droite). CurrentMillis et PreviousMillis conservent les durées en millisecondes de parcours de la boucle. Quand « interval » est atteint (fixé au début), |
Le if/else intérieur contrôle juste l' | Le if/else intérieur contrôle juste l' | ||
Ligne 231: | Ligne 231: | ||
} | } | ||
- | Si la température dépasse 24 °C, la lampe s' | + | Si la température dépasse 24 °C, la lampe s' |
Ligne 243: | Ligne 243: | ||
You may need to allow for that event in your code, otherwise, your code will stop working when it occurs. For example. if a “long” is 4 bytes, and if the time unit is actual millisecs, then this code will fail after 49 days operation (at most!).** | You may need to allow for that event in your code, otherwise, your code will stop working when it occurs. For example. if a “long” is 4 bytes, and if the time unit is actual millisecs, then this code will fail after 49 days operation (at most!).** | ||
- | Notes de Mike K. - Ingénieur | + | Notes de Mike K., ingénieur |
- | Ronnie écrit : écoutez ce gars. Il en connaît beaucoup plus que moi. | + | Ronnie écrit : écoutez ce gars. Il en connaît beaucoup plus que moi ! |
- | Dépassement de la temporisation : Dans le monde réel, vous ne devriez pas avoir besoin de déterminer la valeur maximale de la variable « currentMillis » parce que, tôt ou tard, elle sera remise à zéro. | + | Dépassement de la temporisation : dans le monde réel, vous ne devriez pas avoir besoin de déterminer la valeur maximale de la variable « currentMillis » parce que, tôt ou tard, elle sera remise à zéro. |
- | Vous pourriez avoir besoin de prévoir cet événement | + | Vous pourriez avoir besoin de prévoir cet événement |
**Temperature triggers: In the real world, your temp sensor might be “noisy”, | **Temperature triggers: In the real world, your temp sensor might be “noisy”, | ||
Ligne 257: | Ligne 257: | ||
• If we can read the current state of the device, then the above “Device_State” variable is not needed. And, reverse the above references to ON/OFF, if appropriate.** | • If we can read the current state of the device, then the above “Device_State” variable is not needed. And, reverse the above references to ON/OFF, if appropriate.** | ||
- | Seuils de température : Dans le monde réel, votre détecteur de température pourrait être « bruité » et, dans ce cas, quand la température est « autour de 24 », la lecture pourrait tourner autour de 23/24/25, avec de nombreux changements. Si ça arrive, le code pourrait | + | Seuils de température : dans le monde réel, votre détecteur de température pourrait être « bruité » et, dans ce cas, quand la température est « autour de 24 », la lecture pourrait tourner autour de 23/24/25, avec de nombreux changements. Si ça arrive, le code pourrait |
- | • Dans le code d' | + | • Dans le code d' |
• Si la nouvelle température est à la valeur basse (ou en-dessous), | • Si la nouvelle température est à la valeur basse (ou en-dessous), | ||
• Si la nouvelle température est à la valeur haute (ou au-dessus), et que l' | • Si la nouvelle température est à la valeur haute (ou au-dessus), et que l' | ||
- | • Si vous pouvez lire l' | + | • Si vous pouvez lire l' |
**Wiring: When cutting the mains cable, strip back the outer insulation very slowly and carefully, and do not damage or cut into the wires which are not used by the relay circuit. If there is an earth cable, and if there is an earthing connector in the SSR circuit, then, do not cut the earth cable, but strip about 1-2 cm of it, fold it, and insert it into the earth connector. | **Wiring: When cutting the mains cable, strip back the outer insulation very slowly and carefully, and do not damage or cut into the wires which are not used by the relay circuit. If there is an earth cable, and if there is an earthing connector in the SSR circuit, then, do not cut the earth cable, but strip about 1-2 cm of it, fold it, and insert it into the earth connector. | ||
Ligne 267: | Ligne 267: | ||
For safety, the SSR circuit must be enclosed in a suitable protective box. If the relays get hot when being used, then ensure there is adequate ventilation in the box, and ensure the box is not placed on soft surfaces such as carpets, duvets, etc - which would inhibit ventilation.** | For safety, the SSR circuit must be enclosed in a suitable protective box. If the relays get hot when being used, then ensure there is adequate ventilation in the box, and ensure the box is not placed on soft surfaces such as carpets, duvets, etc - which would inhibit ventilation.** | ||
- | Câblage : Quand vous coupez les câbles d' | + | Câblage : Quand vous coupez les câbles d' |
- | Par sécurité, le circuit du RS doit être placé dans une enveloppe protectrice adaptée. Si les relais deviennent chauds à l' | + | Par sécurité, le circuit du RS doit être placé dans une enveloppe protectrice adaptée. Si les relais deviennent chauds à l' |
**A user might install two relays - one on the positive and one on the negative lines. If a single relay is used - as in this project - it must be connected into the LIVE wire, so that, when the device (lamp, etc) is " | **A user might install two relays - one on the positive and one on the negative lines. If a single relay is used - as in this project - it must be connected into the LIVE wire, so that, when the device (lamp, etc) is " | ||
Ligne 279: | Ligne 279: | ||
L' | L' | ||
- | Caractéristiques du relais : Assurez-vous que le relais peut facilement supporter la tension secteur (110 V AC ou 240 V AC), ainsi que la courant maximal absorbé par les appareils. Par exemple, une lampe à incandescence pourrait absorber 1 A, alors qu'un radiateur électrique pourrait utiliser 20 A. | + | Caractéristiques du relais : Assurez-vous que le relais peut facilement supporter la tension secteur (110 V AC ou 240 V AC), ainsi que la courant maximal absorbé par les appareils. Par exemple, une lampe à incandescence pourrait absorber 1 A, alors qu'un radiateur électrique pourrait utiliser 20 A ou plus. |
- | Par dessus tout, vous pouvez vous attendre à ce que des fans d' | + | En général, vous pouvez vous attendre à ce que des fans d' |
issue107/arduino.1460066992.txt.gz · Dernière modification : 2016/04/08 00:09 de erlevo